git: 9front

Download patch

ref: 7e7db2a9ce3cbe947415259b3dbda02a8fcb26d1
parent: 014f77a83c9c987ca1a8a44ba77a1677f7c65652
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat May 31 10:08:29 EDT 2025

cc: OLABEL and OCASE nodes do not chain on Node.right (fixes case range warning)

The code appers to have had some unused feature
where OLABEL and OCASE nodes where threated like
OLIST/OCOMMA where after generation it would chain
on the Node.right pointer to the next one.

Hoever, this appears to be unused. And when compiling
OCASE nodes with a range then Node.right points
to the end-range constant, which we should not
compile (it left a value not used error).

--- a/sys/src/cmd/cc/pgen.c
+++ b/sys/src/cmd/cc/pgen.c
@@ -190,8 +190,6 @@
 	case OLIST:
 	case OCOMMA:
 		gen(n->left);
-
-	rloop:
 		n = n->right;
 		goto loop;
 
@@ -253,7 +251,7 @@
 		}
 		gbranch(OGOTO);	/* prevent self reference in reg */
 		patch(p, pc);
-		goto rloop;
+		break;
 
 	case OGOTO:
 		canreach = 0;
@@ -289,24 +287,24 @@
 			cases->def = 1;
 			cases->label = pc;
 			cases->isv = 0;
-			goto rloop;
+			break;
 		}
 		complex(l);
 		if(l->type == T)
-			goto rloop;
+			break;
 		if(l->op != OCONST || !typeswitch[l->type->etype]) {
 			diag(n, "case expression must be integer constant");
-			goto rloop;
+			break;
 		}
 		if(r != Z){
 			complex(r);
 			if(r->op != OCONST || !typeswitch[r->type->etype]) {
 				diag(n, "case expression must be integer constant");
-				goto rloop;
+				break;
 			}
 			if(r->vconst < l->vconst){
 				diag(n, "case range must be increasing");
-				goto rloop;
+				break;
 			}
 			end = r->vconst;
 		} else
@@ -319,7 +317,7 @@
 			cases->label = pc;
 			cases->isv = typev[l->type->etype];
 		}
-		goto rloop;
+		break;
 
 	case OSWITCH:
 		l = n->left;
--- a/sys/src/cmd/cc/sub.c
+++ b/sys/src/cmd/cc/sub.c
@@ -2067,7 +2067,7 @@
 	case OCASE:
 		if(!caseok)
 			return 0;
-		goto rloop;
+		break;
 
 	case OSWITCH:
 		return deadhead(n->right, 1);
--