Made able to recognize global declarations of static arrays. Fixed Issue #975.
This commit is contained in:
@@ -151,14 +151,17 @@ static void Parse (void)
|
|||||||
** This means that "extern int i;" will not get storage allocated.
|
** This means that "extern int i;" will not get storage allocated.
|
||||||
*/
|
*/
|
||||||
if ((Decl.StorageClass & SC_FUNC) != SC_FUNC &&
|
if ((Decl.StorageClass & SC_FUNC) != SC_FUNC &&
|
||||||
(Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF &&
|
(Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF) {
|
||||||
((Spec.Flags & DS_DEF_STORAGE) != 0 ||
|
if ((Spec.Flags & DS_DEF_STORAGE) != 0 ||
|
||||||
(Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC ||
|
(Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC ||
|
||||||
((Decl.StorageClass & SC_EXTERN) != 0 &&
|
((Decl.StorageClass & SC_EXTERN) != 0 &&
|
||||||
CurTok.Tok == TOK_ASSIGN))) {
|
CurTok.Tok == TOK_ASSIGN)) {
|
||||||
|
/* We will allocate storage */
|
||||||
/* We will allocate storage */
|
Decl.StorageClass |= SC_STORAGE;
|
||||||
Decl.StorageClass |= SC_STORAGE;
|
} else {
|
||||||
|
/* It's a declaration */
|
||||||
|
Decl.StorageClass |= SC_DECL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this is a function declarator that is not followed by a comma
|
/* If this is a function declarator that is not followed by a comma
|
||||||
@@ -243,7 +246,11 @@ static void Parse (void)
|
|||||||
if (!IsTypeArray (Decl.Type)) {
|
if (!IsTypeArray (Decl.Type)) {
|
||||||
Error ("Variable '%s' has unknown size", Decl.Ident);
|
Error ("Variable '%s' has unknown size", Decl.Ident);
|
||||||
}
|
}
|
||||||
Entry->Flags &= ~(SC_STORAGE | SC_DEF);
|
/* Do this only if the same array has not been defined */
|
||||||
|
if (!SymIsDef (Entry)) {
|
||||||
|
Entry->Flags &= ~(SC_STORAGE | SC_DEF);
|
||||||
|
Entry->Flags |= SC_DECL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* A global (including static) uninitialized variable is
|
/* A global (including static) uninitialized variable is
|
||||||
** only a tentative definition. For example, this is valid:
|
** only a tentative definition. For example, this is valid:
|
||||||
|
|||||||
@@ -802,7 +802,7 @@ static void Primary (ExprDesc* E)
|
|||||||
E->Name = Sym->V.R.RegOffs;
|
E->Name = Sym->V.R.RegOffs;
|
||||||
} else if ((Sym->Flags & SC_STATIC) == SC_STATIC) {
|
} else if ((Sym->Flags & SC_STATIC) == SC_STATIC) {
|
||||||
/* Static variable */
|
/* Static variable */
|
||||||
if (Sym->Flags & (SC_EXTERN | SC_STORAGE)) {
|
if (Sym->Flags & (SC_EXTERN | SC_STORAGE | SC_DECL)) {
|
||||||
E->Flags = E_LOC_GLOBAL | E_RTYPE_LVAL;
|
E->Flags = E_LOC_GLOBAL | E_RTYPE_LVAL;
|
||||||
E->Name = (uintptr_t) Sym->Name;
|
E->Name = (uintptr_t) Sym->Name;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user