mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 02:30:44 +00:00
Made able to recognize global declarations of static arrays. Fixed Issue #975.
This commit is contained in:
parent
0250c87ac6
commit
65081aebed
@ -151,14 +151,17 @@ static void Parse (void)
|
||||
** This means that "extern int i;" will not get storage allocated.
|
||||
*/
|
||||
if ((Decl.StorageClass & SC_FUNC) != SC_FUNC &&
|
||||
(Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF &&
|
||||
((Spec.Flags & DS_DEF_STORAGE) != 0 ||
|
||||
(Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC ||
|
||||
((Decl.StorageClass & SC_EXTERN) != 0 &&
|
||||
CurTok.Tok == TOK_ASSIGN))) {
|
||||
|
||||
/* We will allocate storage */
|
||||
Decl.StorageClass |= SC_STORAGE;
|
||||
(Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF) {
|
||||
if ((Spec.Flags & DS_DEF_STORAGE) != 0 ||
|
||||
(Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC ||
|
||||
((Decl.StorageClass & SC_EXTERN) != 0 &&
|
||||
CurTok.Tok == TOK_ASSIGN)) {
|
||||
/* We will allocate 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
|
||||
@ -243,7 +246,11 @@ static void Parse (void)
|
||||
if (!IsTypeArray (Decl.Type)) {
|
||||
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 {
|
||||
/* A global (including static) uninitialized variable is
|
||||
** only a tentative definition. For example, this is valid:
|
||||
|
@ -802,7 +802,7 @@ static void Primary (ExprDesc* E)
|
||||
E->Name = Sym->V.R.RegOffs;
|
||||
} else if ((Sym->Flags & SC_STATIC) == SC_STATIC) {
|
||||
/* 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->Name = (uintptr_t) Sym->Name;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user