1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-22 17:29:34 +00:00

Merge pull request #2075 from bbbradsmith/struct-duplicate-member-error

Error for struct/union with a duplicate member
This commit is contained in:
Bob Andrews 2023-05-04 22:43:17 +02:00 committed by GitHub
commit a7676bdff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -793,6 +793,8 @@ static int HandleSymRedefinition (SymEntry* Sym, const Type* T, unsigned Flags)
*/
Error ("Redeclaration of enumerator constant '%s'", Sym->Name);
Sym = 0;
} else if (Flags & SC_STRUCTFIELD) {
Error ("Duplicate member '%s'", Sym->Name);
}
}
}

View File

@ -0,0 +1,17 @@
/* Ensure that a duplicate member in a struct produces an error.
** https://github.com/cc65/cc65/issues/2015
*/
struct bads {
int a;
int a; /* this is an error */
};
union badu {
int a, a; /* also an error */
};
int main(void)
{
return 0;
}