shithub: scc

Download patch

ref: 1b6227fff18f7388065016b4dde3346e2683ae19
parent: 452bac14b4bf430cf4435943f4478abd5f309686
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Jul 5 08:50:36 EDT 2013

Assign type int by default to identifiers in outer context

It is possible declare a variable in the extern context using
only the name of the variable. In this case we will not have
a ctype struct, so we have to create a new one and assign the
int type.

--- a/decl.c
+++ b/decl.c
@@ -222,8 +222,10 @@
 	while (accept(';'))
 		/* nothing */;
 	if (!(tp = spec())) {
-		if (curctx != CTX_OUTER)
+		if (curctx != CTX_OUTER || yytoken != IDEN)
 			goto end;
+		tp = newctype();
+		tp->type = INT;
 		warning("data definition has no type or storage class");
 	}
 	if (accept(';')) {