aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2017-04-25 14:10:52 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2017-04-25 14:10:52 +0000
commitfbe91804589555b48f00e1e26b98096745fc6882 (patch)
tree95dffe7a23f7b79c3d296372f0180e4047adeda3 /gcc
parent1c4ea66f24bc3801448d5c88847fc97d4e2767ee (diff)
downloadgcc-fbe91804589555b48f00e1e26b98096745fc6882.zip
gcc-fbe91804589555b48f00e1e26b98096745fc6882.tar.gz
gcc-fbe91804589555b48f00e1e26b98096745fc6882.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/parser.c6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/semicolon-fixits.C17
4 files changed, 31 insertions, 1 deletions
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 <dmalcolm@redhat.com>
+ * parser.c (cp_parser_member_declaration): Add fix-it hint
+ for removing stray semicolons.
+
+2017-04-25 David Malcolm <dmalcolm@redhat.com>
+
* 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 <dmalcolm@redhat.com>
+ * g++.dg/semicolon-fixits.C: New test case.
+
+2017-04-25 David Malcolm <dmalcolm@redhat.com>
+
* gcc.dg/semicolon-fixits.c: New test case.
2017-04-25 David Malcolm <dmalcolm@redhat.com>
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 "" } */