@@ -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,70 @@ 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
1796
+ if (parser_stack($3 ).is_not_nil())
1797
+ {
1798
+ parser_stack ($1 ).set(ID_underlying_type, parser_stack($3 ));
1799
+ }
1795
1800
}
1796
1801
' {' enumerator_list_opt ' }'
1797
1802
gcc_type_attribute_opt
1798
1803
{
1799
- parser_stack ($1 ).operands().swap(parser_stack($5 ).operands());
1800
- $$ =merge($1 , merge($2 , $7 )); // throw in the gcc attributes
1804
+ parser_stack ($1 ).operands().swap(parser_stack($6 ).operands());
1805
+ $$ =merge($1 , merge($2 , $8 )); // throw in the gcc attributes
1801
1806
}
1802
1807
| enum_key
1803
1808
gcc_type_attribute_opt
1804
1809
identifier_or_typedef_name
1810
+ enum_underlying_type_opt
1805
1811
{
1806
1812
// an enum with tag
1807
1813
parser_stack ($1 ).set(ID_tag, parser_stack($3 ));
1814
+
1815
+ if (parser_stack($4 ).is_not_nil())
1816
+ {
1817
+ parser_stack ($1 ).set(ID_underlying_type, parser_stack($4 ));
1818
+ }
1808
1819
}
1809
- ' { ' enumerator_list_opt ' } '
1820
+ braced_enumerator_list_opt
1810
1821
gcc_type_attribute_opt
1811
1822
{
1812
- parser_stack ($1 ).operands().swap(parser_stack($6 ).operands());
1813
- $$ =merge($1 , merge($2 , $8 )); // throw in the gcc attributes
1823
+ if (parser_stack($6 ).is_not_nil())
1824
+ {
1825
+ parser_stack ($1 ).operands().swap(parser_stack($6 ).operands());
1826
+ }
1827
+ else
1828
+ {
1829
+ parser_stack ($1 ).id(ID_c_enum_tag);
1830
+ }
1831
+
1832
+ $$ =merge($1 , merge($2 , $7 )); // throw in the gcc attributes
1814
1833
}
1815
- | enum_key
1816
- gcc_type_attribute_opt
1817
- identifier_or_typedef_name
1818
- gcc_type_attribute_opt
1834
+ ;
1835
+
1836
+ enum_underlying_type_opt :
1837
+ /* empty */
1819
1838
{
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
1839
+ init ($$);
1840
+ parser_stack ($$).make_nil();
1841
+ }
1842
+ | ' :' basic_type_name
1843
+ {
1844
+ $$ =$2 ;
1845
+ }
1846
+
1847
+ braced_enumerator_list_opt :
1848
+ /* empty */
1849
+ {
1850
+ init ($$);
1851
+ parser_stack ($$).make_nil();
1852
+ }
1853
+ | ' {' enumerator_list_opt ' }'
1854
+ {
1855
+ $$ =$2 ;
1823
1856
}
1824
- ;
1825
1857
1826
1858
enum_key : TOK_ENUM
1827
1859
{
0 commit comments