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:
@@ -1833,10 +1833,22 @@ static unsigned ParseStructInit (Type* T, int AllowFlexibleMembers)
|
|||||||
* last struct field).
|
* last struct field).
|
||||||
*/
|
*/
|
||||||
Size += ParseInitInternal (Entry->Type, AllowFlexibleMembers && Entry->NextSym == 0);
|
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;
|
break;
|
||||||
NextToken ();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Consume the closing curly brace */
|
/* Consume the closing curly brace */
|
||||||
|
|||||||
Reference in New Issue
Block a user