Merge pull request #2287 from acqn/Diagnostics

[cc65] Minor diagnostics improvements
This commit is contained in:
Bob Andrews 2023-12-09 22:16:47 +01:00 committed by GitHub
commit a16a6298e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 19 deletions

View File

@ -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);
}

View File

@ -178,7 +178,7 @@ static void CheckSymTable (SymTable* Tab)
if (IS_Get (&WarnUnusedFunc)) {
Warning ("Function '%s' is defined but never used", Entry->Name);
}
} else {
} else if (!IsAnonName (Entry->Name)) {
if (IS_Get (&WarnUnusedVar)) {
Warning ("Variable '%s' is defined but never used", Entry->Name);
}
@ -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;
}
}
}