From: David Malcolm Date: Tue, 25 Apr 2017 14:10:52 +0000 (+0000) Subject: C++: fix-it hint for removing stray semicolons X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fbe91804589555b48f00e1e26b98096745fc6882;p=gcc.git C++: fix-it hint for removing stray semicolons gcc/cp/ChangeLog: * parser.c (cp_parser_member_declaration): Add fix-it hint for removing stray semicolons. gcc/testsuite/ChangeLog: * g++.dg/semicolon-fixits.C: New test case. From-SVN: r247244 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ff80b33539d..9c8ad1077e4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-04-25 David Malcolm + + * parser.c (cp_parser_member_declaration): Add fix-it hint + for removing stray semicolons. + 2017-04-25 David Malcolm * name-lookup.c (get_std_name_hint): New function. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 31eb3d2e155..c9780f801db 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23127,7 +23127,11 @@ cp_parser_member_declaration (cp_parser* parser) { cp_token *token = cp_lexer_peek_token (parser->lexer); if (!in_system_header_at (token->location)) - pedwarn (token->location, OPT_Wpedantic, "extra %<;%>"); + { + gcc_rich_location richloc (token->location); + richloc.add_fixit_remove (); + pedwarn_at_rich_loc (&richloc, OPT_Wpedantic, "extra %<;%>"); + } } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b369bb5b839..2c00ce85398 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-04-25 David Malcolm + + * g++.dg/semicolon-fixits.C: New test case. + 2017-04-25 David Malcolm * gcc.dg/semicolon-fixits.c: New test case. diff --git a/gcc/testsuite/g++.dg/semicolon-fixits.C b/gcc/testsuite/g++.dg/semicolon-fixits.C new file mode 100644 index 00000000000..a9cc783b172 --- /dev/null +++ b/gcc/testsuite/g++.dg/semicolon-fixits.C @@ -0,0 +1,17 @@ +/* { dg-options "-fdiagnostics-show-caret -Wpedantic" } */ + +/* Struct with extra semicolon. */ +struct s1 { int i;; }; /* { dg-warning "19: extra .;." } */ +/* { dg-begin-multiline-output "" } + struct s1 { int i;; }; + ^ + - + { dg-end-multiline-output "" } */ + +/* Union with extra semicolon. */ +union u1 { int i;; }; /* { dg-warning "18: extra .;." } */ +/* { dg-begin-multiline-output "" } + union u1 { int i;; }; + ^ + - + { dg-end-multiline-output "" } */