ref: 2abdf1c09b5cb1217625acdefaa8de44fe1aa15d
parent: 8bcf160b21f60b00bf753905687b61b69a117577
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Jul 10 10:10:47 EDT 2014
Improve isglobal and isdefined flags in external decl The code was a bit messy, and this version is clearer.
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -446,8 +446,6 @@
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 {
@@ -454,11 +452,20 @@
sym = declarator(base, ID_EXPECTED);
tp = sym->type;
sym->s.isstatic = 1;
+ sym->s.isglobal= 1;
+ sym->s.isdefined = 1;
- if (sclass != STATIC)
- sym->s.isglobal = 1;
- else if (sclass != EXTERN)
- 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('='))