Fix missing value for first item of enums with trailing comma
The value of the first item of an enum with a trailing comma after its
last item was not correctly initialized to 0 any more after the changes
of 74adaa5738 (see #1515) because "_last"
attribute was not set correctly in this case.
Do set it for the last item when it's followed by a comma too and add
more unit tests checking for this.
Closes #1566.
This commit is contained in:
parent
2db6b42715
commit
c321aca2b4
3 changed files with 31 additions and 0 deletions
|
|
@ -6375,6 +6375,12 @@ optional_ignored_defines
|
|||
;
|
||||
|
||||
/* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */
|
||||
|
||||
/*
|
||||
Note that "_last" attribute is not supposed to be set on the last enum element, as might be expected from its name, but on the _first_ one, and _only_ on it,
|
||||
so we propagate it back to the first item while parsing and reset it on all the subsequent ones.
|
||||
*/
|
||||
|
||||
enumlist : enumlist_item {
|
||||
Setattr($1,"_last",$1);
|
||||
$$ = $1;
|
||||
|
|
@ -6389,6 +6395,8 @@ enumlist : enumlist_item {
|
|||
set_nextSibling($1, $3);
|
||||
Setattr($1,"_last",Getattr($3,"_last"));
|
||||
Setattr($3,"_last",NULL);
|
||||
} else {
|
||||
Setattr($1,"_last",$1);
|
||||
}
|
||||
$$ = $1;
|
||||
}
|
||||
|
|
@ -6397,6 +6405,8 @@ enumlist : enumlist_item {
|
|||
set_nextSibling($1, $4);
|
||||
Setattr($1,"_last",Getattr($4,"_last"));
|
||||
Setattr($4,"_last",NULL);
|
||||
} else {
|
||||
Setattr($1,"_last",$1);
|
||||
}
|
||||
set_comment($1, $3);
|
||||
$$ = $1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue