shithub: scc

Download patch

ref: 8bcf160b21f60b00bf753905687b61b69a117577
parent: 60593515d461f8665b59f7c51eca7556fff69256
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Jul 10 09:55:26 EDT 2014

Set isdefined bit in local declarations

All the local definitions are definitions, excepts if they are
labelled as extern.

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -400,21 +400,24 @@
 	int8_t sclass;
 
 	tp = specifier(&sclass);
-	if (yytoken != ';') {
-		do {
-			sym = declarator(tp, ID_EXPECTED);
-			switch (sclass) {
-			case REGISTER: sym->s.isregister = 1; break;
-			case STATIC: sym->s.isstatic = 1; break;
-			case EXTERN: /* TODO: */; break;
-			case TYPEDEF: /* TODO: */;break;
-			case AUTO: default: sym->s.isauto = 1;
-			}
-			if (accept('='))
-				initializer(sym);
-			emitdcl(sym);
-		} while (accept(','));
-	}
+	if (accept(';'))
+		return;
+
+	do {
+		sym = declarator(tp, ID_EXPECTED);
+		sym->s.isdefined = 1;
+		switch (sclass) {
+		case REGISTER: sym->s.isregister = 1; break;
+		case STATIC: sym->s.isstatic = 1; break;
+		case EXTERN: sym->s.isdefined = 0; break;
+		case TYPEDEF: /* TODO: */;break;
+		case AUTO: default: sym->s.isauto = 1;
+		}
+		if (accept('='))
+			initializer(sym);
+		emitdcl(sym);
+	} while (accept(','));
+
 	expect(';');
 }