scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 1b6227fff18f7388065016b4dde3346e2683ae19
parent 452bac14b4bf430cf4435943f4478abd5f309686
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Jul 2013 12:50:36 +0200

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.

Diffstat:
Mdecl.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/decl.c b/decl.c @@ -222,8 +222,10 @@ decl(void) 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(';')) {