From 29c9cb3e0063c8cfe6fbf64e4ad53dc41d462298 Mon Sep 17 00:00:00 2001 From: acqn Date: Thu, 29 Sep 2022 19:38:32 +0800 Subject: [PATCH] Improved diagnostics on conflicting type declarations. --- src/cc65/symtab.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index aa4a9a44a..7de889d39 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -702,6 +702,7 @@ static int HandleSymRedefinition (SymEntry* Entry, const Type* T, unsigned Flags if (SCType == SC_TYPEDEF) { if (IsDistinctRedef (E_Type, T, TC_IDENTICAL, TCF_MASK_QUAL)) { Error ("Conflicting types for typedef '%s'", Entry->Name); + Note ("'%s' vs '%s'", GetFullTypeName (T), GetFullTypeName (E_Type)); Entry = 0; } } else { @@ -728,7 +729,7 @@ static int HandleSymRedefinition (SymEntry* Entry, const Type* T, unsigned Flags /* New type must be compatible with the composite prototype */ if (IsDistinctRedef (E_Type, T, TC_EQUAL, TCF_MASK_QUAL)) { Error ("Conflicting function types for '%s'", Entry->Name); - TypeCompatibilityDiagnostic (T, E_Type, 0, "'%s' vs '%s'"); + Note ("'%s' vs '%s'", GetFullTypeName (T), GetFullTypeName (E_Type)); Entry = 0; } else { /* Refine the existing composite prototype with this new @@ -760,6 +761,7 @@ static int HandleSymRedefinition (SymEntry* Entry, const Type* T, unsigned Flags IsDistinctRedef (E_Type + 1, T + 1, TC_IDENTICAL, TCF_MASK_QUAL)) { /* Conflicting element types */ Error ("Conflicting array types for '%s[]'", Entry->Name); + Note ("'%s' vs '%s'", GetFullTypeName (T), GetFullTypeName (E_Type)); Entry = 0; } else { /* Check if we have a size in the existing definition */ @@ -777,6 +779,7 @@ static int HandleSymRedefinition (SymEntry* Entry, const Type* T, unsigned Flags Entry = 0; } else if (IsDistinctRedef (E_Type, T, TC_EQUAL, TCF_MASK_QUAL)) { Error ("Conflicting types for '%s'", Entry->Name); + Note ("'%s' vs '%s'", GetFullTypeName (T), GetFullTypeName (E_Type)); Entry = 0; } else if (E_SCType == SC_ENUMERATOR) { /* Enumerators aren't allowed to be redeclared at all, even if