Made a C union declaration know the sizes of anonymous struct/union members when it determines its size.

The bug was located, and the fix was written, by Francesco.
This commit is contained in:
Greg King
2018-05-13 04:21:42 -04:00
parent 4e137cf9f5
commit 362b6afacf
3 changed files with 268 additions and 2 deletions

View File

@@ -656,13 +656,16 @@ static SymEntry* ParseUnionDecl (const char* Name)
/* Check for fields without a name */
if (Decl.Ident[0] == '\0') {
/* In cc65 mode, we allow anonymous structs/unions within
** a struct.
** a union.
*/
if (IS_Get (&Standard) >= STD_CC65 && IsClassStruct (Decl.Type)) {
/* This is an anonymous struct or union. Copy the fields
** into the current level.
*/
CopyAnonStructFields (&Decl, 0);
FieldSize = CopyAnonStructFields (&Decl, 0);
if (FieldSize > UnionSize) {
UnionSize = FieldSize;
}
} else {
/* A non bit-field without a name is legal but useless */