Commit 70caf430 by Volker Reichelt Committed by Volker Reichelt

parser.c (cp_parser_elaborated_type_specifier): Add fix-it to diagnostic of…

parser.c (cp_parser_elaborated_type_specifier): Add fix-it to diagnostic of invalid class/struct keyword after enum.

        * parser.c (cp_parser_elaborated_type_specifier): Add fix-it to
        diagnostic of invalid class/struct keyword after enum.

        * g++.dg/cpp0x/enum34.C: New test.

From-SVN: r247254
parent 9c533e7d
2017-04-25 Volker Reichelt <v.reichelt@netcologne.de>
* parser.c (cp_parser_elaborated_type_specifier): Add fix-it to
diagnostic of invalid class/struct keyword after enum.
2017-04-25 David Malcolm <dmalcolm@redhat.com> 2017-04-25 David Malcolm <dmalcolm@redhat.com>
* parser.c (cp_parser_member_declaration): Add fix-it hint * parser.c (cp_parser_member_declaration): Add fix-it hint
......
...@@ -17270,12 +17270,16 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, ...@@ -17270,12 +17270,16 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
tag_type = enum_type; tag_type = enum_type;
/* Issue a warning if the `struct' or `class' key (for C++0x scoped /* Issue a warning if the `struct' or `class' key (for C++0x scoped
enums) is used here. */ enums) is used here. */
if (cp_lexer_next_token_is_keyword (parser->lexer, RID_CLASS) cp_token *token = cp_lexer_peek_token (parser->lexer);
|| cp_lexer_next_token_is_keyword (parser->lexer, RID_STRUCT)) if (cp_parser_is_keyword (token, RID_CLASS)
|| cp_parser_is_keyword (token, RID_STRUCT))
{ {
pedwarn (input_location, 0, "elaborated-type-specifier " gcc_rich_location richloc (token->location);
"for a scoped enum must not use the %qD keyword", richloc.add_range (input_location, false);
cp_lexer_peek_token (parser->lexer)->u.value); richloc.add_fixit_remove ();
pedwarn_at_rich_loc (&richloc, 0, "elaborated-type-specifier for "
"a scoped enum must not use the %qD keyword",
token->u.value);
/* Consume the `struct' or `class' and parse it anyway. */ /* Consume the `struct' or `class' and parse it anyway. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
} }
2017-04-25 Volker Reichelt <v.reichelt@netcologne.de>
* g++.dg/cpp0x/enum34.C: New test.
2017-04-25 Tom de Vries <tom@codesourcery.com> 2017-04-25 Tom de Vries <tom@codesourcery.com>
* lib/gcc-dg.exp (cleanup-after-saved-dg-test): Cleanup line number * lib/gcc-dg.exp (cleanup-after-saved-dg-test): Cleanup line number
......
// { dg-options "-fdiagnostics-show-caret" }
// { dg-do compile { target c++11 } }
enum class E;
enum class E e; /* { dg-warning "scoped enum must not use" }
{ dg-begin-multiline-output "" }
enum class E e;
~~~~ ^~~~~
-----
{ dg-end-multiline-output "" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment