1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-26 17:36:57 +00:00

Fixed an error: When initializing unions, only the first member can be

initialized.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4121 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-09-06 16:44:16 +00:00
parent 78a7af13e6
commit 2402ef005e

View File

@ -1833,10 +1833,22 @@ static unsigned ParseStructInit (Type* T, int AllowFlexibleMembers)
* last struct field).
*/
Size += ParseInitInternal (Entry->Type, AllowFlexibleMembers && Entry->NextSym == 0);
Entry = Entry->NextSym;
if (CurTok.Tok != TOK_COMMA)
/* For unions, only the first member can be initialized */
if (IsTypeStruct (T)) {
/* Struct */
Entry = Entry->NextSym;
} else {
/* Union */
Entry = 0;
}
/* More initializers? */
if (CurTok.Tok == TOK_COMMA) {
NextToken ();
} else {
break;
NextToken ();
}
}
/* Consume the closing curly brace */