shithub: scc

Download patch

ref: cfd05d23cb1e3716f9d59e1ad95bbb29c4da713b
parent: dbd4a25ef1165b87b3848ad1d7e64beb663b6329
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Aug 14 18:02:23 EDT 2015

Reserve always an identifier for labels

Labels are always emitted, so they must have an identifier
always. Before this patch temporal labels were not installed
because they don't have name, and it caused that all the
temporal labels hadn't an identifier, they were emitted
as L0.

--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -166,6 +166,7 @@
 		return sym;
 	if (ns == NS_LABEL) {
 		sym->next = labels;
+		sym->id = ++localcnt;
 		return labels = sym;
 	}
 
@@ -260,7 +261,7 @@
 	sym = linkhash(newsym(ns), sym->name);
 
 assign_id:
-	if (sym->ns != NS_CPP)
+	if (sym->ns != NS_CPP || sym->ns != NS_LABEL)
 		sym->id = (curctx) ? ++localcnt : ++globalcnt;
 
 	return sym;
--- a/cc1/tests/test004.c
+++ b/cc1/tests/test004.c
@@ -22,9 +22,9 @@
 	A2	A2	A2	#I3	<I	#I1	#I0	?I	+I	:I
 	A2	A2	A2	#I1	>I	#I1	#I0	?I	+I	:I
 	A2	A2	A2	#I4	<I	#I1	#I0	?I	+I	:I
-	j	L0	A2	#I4	=I
+	j	L3	A2	#I4	=I
 	yI	#I1
-L0
+L3
 	yI	#I0
 }
 */
@@ -52,4 +52,4 @@
 	if(x != 4)
 		return 1;
 	return 0;
-}
\ No newline at end of file
+}
--- a/cc1/tests/test005.c
+++ b/cc1/tests/test005.c
@@ -12,9 +12,9 @@
 	A2	A2	#I0	=I	#I1	#I0	?I	:I
 	A2	A2	~I	:I
 	A2	A2	_I	:I
-	j	L0	A2	#I2	=I
+	j	L3	A2	#I2	=I
 	yI	#I1
-L0
+L3
 	yI	#I0
 }
 */