On Wed, Nov 14, 2018 at 9:55 AM Marek Polacek <pola...@redhat.com> wrote: > > In elaborated-type-specifier, the typename keyword can only follow a > nested-name-specifier: > > class-key nested-name-specifier template[opt] simple-template-id > > but we weren't detecting it. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > 2018-11-14 Marek Polacek <pola...@redhat.com> > > PR c++/87781 - detect invalid elaborated-type-specifier. > * parser.c (cp_parser_elaborated_type_specifier): Ensure that > typename follows a nested-name-specifier. > > * g++.dg/parse/elab3.C: New test. > > diff --git gcc/cp/parser.c gcc/cp/parser.c > index e9e49b15702..0ab44ab93e3 100644 > --- gcc/cp/parser.c > +++ gcc/cp/parser.c > @@ -17986,6 +17986,10 @@ cp_parser_elaborated_type_specifier (cp_parser* > parser, > template-id or not. */ > if (!template_p) > cp_parser_parse_tentatively (parser); > + /* The `template' keyword must follow a nested-name-specifier. */ > + else if (!nested_name_specifier) > + return error_mark_node;
Don't we want a diagnostic here? Jason