From: David Malcolm Date: Tue, 25 Apr 2017 14:10:52 +0000 (+0000) Subject: C++: fix-it hint for removing stray semicolons X-Git-Tag: upstream/12.2.0~40001 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbe91804589555b48f00e1e26b98096745fc6882;p=platform%2Fupstream%2Fgcc.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 ff80b33..9c8ad10 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 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. (maybe_suggest_missing_header): New function. (suggest_alternative_in_explicit_scope): Call diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 31eb3d2..c9780f80 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 b369bb5..2c00ce8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 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. 2017-04-25 David Malcolm diff --git a/gcc/testsuite/g++.dg/semicolon-fixits.C b/gcc/testsuite/g++.dg/semicolon-fixits.C new file mode 100644 index 0000000..a9cc783 --- /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 "" } */