aboutsummaryrefslogtreecommitdiff
path: root/gcc/main.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2021-04-20 12:16:04 -0400
committerMarek Polacek <polacek@redhat.com>2021-04-21 11:12:14 -0400
commit001c63d15e31bc0a1545426d889a0b9f671b4961 (patch)
tree881ad5ea0e5117f0482010a7cc915d94b6ed150c /gcc/main.c
parente9fc9d075f303b50c77c7b497b2982fe6dc7f5c1 (diff)
downloadgcc-001c63d15e31bc0a1545426d889a0b9f671b4961.zip
gcc-001c63d15e31bc0a1545426d889a0b9f671b4961.tar.gz
gcc-001c63d15e31bc0a1545426d889a0b9f671b4961.tar.bz2
c++: Don't allow defining types in enum-base [PR96380]
In r11-2064 I made cp_parser_enum_specifier commit to tentative parse when seeing a '{'. That still looks like the correct thing to do, but it caused an ICE-on-invalid as well as accepts-invalid. When we have something sneaky like this, which is broken in multiple ways: template <class> enum struct c : union enum struct c { e = b, f = a }; we parse the "enum struct c" part (that's OK) and then we see that we have an enum-base, so we consume ':' and then parse the type-specifier that follows the :. "union enum" is clearly invalid, but we're still parsing tentatively and we parse everything up to the ;, and then throw away the underlying type. We parsed everything because we were tricked into parsing an enum-specifier in an enum-base of another enum-specifier! Not good. Since the grammar for enum-base doesn't allow a defining-type-specifier, only a type-specifier, we should set type_definition_forbidden_message which fixes all the problems in this PR. gcc/cp/ChangeLog: PR c++/96380 * parser.c (cp_parser_enum_specifier): Don't allow defining types in enum-base. gcc/testsuite/ChangeLog: PR c++/96380 * g++.dg/cpp0x/enum_base4.C: New test. * g++.dg/cpp0x/enum_base5.C: New test.
Diffstat (limited to 'gcc/main.c')
0 files changed, 0 insertions, 0 deletions