@@ -267,7 +267,7 @@ extern char *yyansi_ctext;
267
267
268
268
%start grammar
269
269
270
- %expect 1 /* the famous "dangling `else'" ambiguity */
270
+ %expect 2 /* the famous "dangling `else'" ambiguity */
271
271
/* results in one shift/reduce conflict */
272
272
/* that we don't want to be reported */
273
273
@@ -1790,38 +1790,54 @@ bit_field_size:
1790
1790
enum_name :
1791
1791
enum_key
1792
1792
gcc_type_attribute_opt
1793
+ enum_underlying_type_opt
1793
1794
{
1794
1795
// an anon enum
1795
1796
}
1796
1797
' {' enumerator_list_opt ' }'
1797
1798
gcc_type_attribute_opt
1798
1799
{
1799
- parser_stack ($1 ).operands().swap(parser_stack($5 ).operands());
1800
- $$ =merge($1 , merge($2 , $7 )); // throw in the gcc attributes
1800
+ parser_stack ($1 ).operands().swap(parser_stack($6 ).operands());
1801
+ $$ =merge($1 , merge($2 , $8 )); // throw in the gcc attributes
1801
1802
}
1802
1803
| enum_key
1803
1804
gcc_type_attribute_opt
1804
1805
identifier_or_typedef_name
1806
+ enum_underlying_type_opt
1805
1807
{
1806
1808
// an enum with tag
1807
1809
parser_stack ($1 ).set(ID_tag, parser_stack($3 ));
1808
1810
}
1809
- ' { ' enumerator_list_opt ' } '
1811
+ braced_enumerator_list_opt
1810
1812
gcc_type_attribute_opt
1811
1813
{
1812
- parser_stack ($1 ).operands().swap(parser_stack($6 ).operands());
1813
- $$ =merge($1 , merge($2 , $8 )); // throw in the gcc attributes
1814
+ if (!parser_stack($6 ).is_nil())
1815
+ {
1816
+ parser_stack ($1 ).operands().swap(parser_stack($6 ).operands());
1817
+ }
1818
+ else
1819
+ {
1820
+ parser_stack ($1 ).id(ID_c_enum_tag);
1821
+ }
1822
+
1823
+ $$ =merge($1 , merge($2 , $7 )); // throw in the gcc attributes
1814
1824
}
1815
- | enum_key
1816
- gcc_type_attribute_opt
1817
- identifier_or_typedef_name
1818
- gcc_type_attribute_opt
1825
+ ;
1826
+
1827
+ enum_underlying_type_opt :
1828
+ /* empty */
1829
+ | ' :' basic_type_name
1830
+
1831
+ braced_enumerator_list_opt :
1832
+ /* empty */
1819
1833
{
1820
- parser_stack ($1 ).id(ID_c_enum_tag); // tag only
1821
- parser_stack ($1 ).set(ID_tag, parser_stack($3 ));
1822
- $$ =merge($1 , merge($2 , $4 )); // throw in the gcc attributes
1834
+ init ($$);
1835
+ parser_stack ($$).make_nil();
1836
+ }
1837
+ | ' {' enumerator_list_opt ' }'
1838
+ {
1839
+ $$ =$2 ;
1823
1840
}
1824
- ;
1825
1841
1826
1842
enum_key : TOK_ENUM
1827
1843
{
0 commit comments