diff --git a/src/cc65/declare.c b/src/cc65/declare.c index b6620785f..96e1f1074 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1220,11 +1220,6 @@ NextMember: if (CurTok.Tok != TOK_COMMA) { Flags |= SC_FICTITIOUS; } - /* Empty union is not supported now */ - if (UnionSize == 0) { - Error ("Empty union type '%s' is not supported", Name); - } - /* Make a real entry from the forward decl and return it */ return AddStructSym (Name, SC_UNION | SC_DEF | Flags, UnionSize, FieldTab, DSFlags); } @@ -1471,11 +1466,6 @@ NextMember: if (CurTok.Tok != TOK_COMMA) { Flags |= SC_FICTITIOUS; } - /* Empty struct is not supported now */ - if (StructSize == 0) { - Error ("Empty struct type '%s' is not supported", Name); - } - /* Make a real entry from the forward decl and return it */ return AddStructSym (Name, SC_STRUCT | SC_DEF | Flags, StructSize, FieldTab, DSFlags); } diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 86a92a019..1b5c1e0b5 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -919,14 +919,8 @@ SymEntry* AddStructSym (const char* Name, unsigned Flags, unsigned Size, SymTabl /* SCType must be struct or union */ PRECONDITION (SCType == SC_STRUCT || SCType == SC_UNION); - if ((Flags & SC_FICTITIOUS) == 0) { - /* Do we have an entry with this name already? */ - TagEntry = FindSymInTable (CurTagTab, Name, HashStr (Name)); - } else { - /* Add a fictitious symbol in the fail-safe table */ - TagEntry = 0; - CurTagTab = FailSafeTab; - } + /* Do we have an entry with this name already? */ + TagEntry = FindSymInTable (CurTagTab, Name, HashStr (Name)); if (TagEntry) { @@ -954,6 +948,15 @@ SymEntry* AddStructSym (const char* Name, unsigned Flags, unsigned Size, SymTabl if (DSFlags != 0) { *DSFlags |= DS_NEW_TYPE_DEF; } + + if ((Flags & SC_FICTITIOUS) == SC_FICTITIOUS) { + /* Add a fictitious symbol in the fail-safe table */ + TagEntry = 0; + } else if (Size == 0) { + /* Empty struct is not supported now */ + Error ("Empty %s type '%s' is not supported", SCType == SC_STRUCT ? "struct" : "union", Name); + TagEntry = 0; + } } }