scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 2abdf1c09b5cb1217625acdefaa8de44fe1aa15d
parent 8bcf160b21f60b00bf753905687b61b69a117577
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 10 Jul 2014 14:10:47 +0200

Improve isglobal and isdefined flags in external decl

The code was a bit messy, and this version is clearer.

Diffstat:
cc1/decl.c | 21++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/cc1/decl.c b/cc1/decl.c @@ -446,19 +446,26 @@ extdecl(void) switch (yytoken) { case IDEN: case TYPE: case SCLASS: case TQUALIFIER: base = specifier(&sclass); - if (sclass == REGISTER || sclass == AUTO) - error("incorrect storage class for file-scope declaration"); if (accept(';')) return; do { sym = declarator(base, ID_EXPECTED); tp = sym->type; sym->s.isstatic = 1; - - if (sclass != STATIC) - sym->s.isglobal = 1; - else if (sclass != EXTERN) - sym->s.isdefined = 1; + sym->s.isglobal= 1; + sym->s.isdefined = 1; + + switch (sclass) { + case REGISTER: case AUTO: + error("incorrect storage class for file-scope declaration"); + case STATIC: + sym->s.isglobal = 0; + break; + case EXTERN: + sym->s.isdefined = 0; + break; + case TYPEDEF: /* TODO: */ break; + } if (BTYPE(tp) != FTN) { if (accept('='))