public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Marek Polacek <mpolacek@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8967] c++: adjust the extra ; warning [PR113760] Date: Tue, 13 Feb 2024 23:08:48 +0000 (GMT) [thread overview] Message-ID: <20240213230848.B85223857BA3@sourceware.org> (raw) https://gcc.gnu.org/g:6fec511f2d23cc70ab29d1ba79c2415ab51bcb60 commit r14-8967-g6fec511f2d23cc70ab29d1ba79c2415ab51bcb60 Author: Marek Polacek <polacek@redhat.com> Date: Tue Feb 13 16:21:32 2024 -0500 c++: adjust the extra ; warning [PR113760] A minimal fix to quash an extra ; warning. I have a more complete patch for GCC 15. DR 1693 PR c++/113760 gcc/cp/ChangeLog: * parser.cc (cp_parser_member_declaration): Only pedwarn about an extra semicolon in C++98. gcc/testsuite/ChangeLog: * g++.dg/semicolon-fixits.C: Run in C++98 only. * g++.dg/warn/pedantic2.C: Adjust dg-warning. * g++.old-deja/g++.jason/parse11.C: Adjust dg-error. * g++.dg/DRs/dr1693-1.C: New test. * g++.dg/DRs/dr1693-2.C: New test. Diff: --- gcc/cp/parser.cc | 2 +- gcc/testsuite/g++.dg/DRs/dr1693-1.C | 9 +++++++++ gcc/testsuite/g++.dg/DRs/dr1693-2.C | 9 +++++++++ gcc/testsuite/g++.dg/semicolon-fixits.C | 1 + gcc/testsuite/g++.dg/warn/pedantic2.C | 4 ++-- gcc/testsuite/g++.old-deja/g++.jason/parse11.C | 4 ++-- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 68ab74d70b9c..9d0914435fb1 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -27999,7 +27999,7 @@ cp_parser_member_declaration (cp_parser* parser) if (!decl_specifiers.any_specifiers_p) { cp_token *token = cp_lexer_peek_token (parser->lexer); - if (!in_system_header_at (token->location)) + if (cxx_dialect < cxx11 && !in_system_header_at (token->location)) { gcc_rich_location richloc (token->location); richloc.add_fixit_remove (); diff --git a/gcc/testsuite/g++.dg/DRs/dr1693-1.C b/gcc/testsuite/g++.dg/DRs/dr1693-1.C new file mode 100644 index 000000000000..ed27026109c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr1693-1.C @@ -0,0 +1,9 @@ +// DR 1693, Superfluous semicolons in class definitions +// PR c++/113760 +// { dg-do compile } +// { dg-options "" } + +struct S { + int a; + ; +}; diff --git a/gcc/testsuite/g++.dg/DRs/dr1693-2.C b/gcc/testsuite/g++.dg/DRs/dr1693-2.C new file mode 100644 index 000000000000..c52259d4602a --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr1693-2.C @@ -0,0 +1,9 @@ +// DR 1693, Superfluous semicolons in class definitions +// PR c++/113760 +// { dg-do compile } +// { dg-options "-pedantic-errors" } + +struct S { + int a; + ; // { dg-error "extra" "" { target c++98_only } } +}; diff --git a/gcc/testsuite/g++.dg/semicolon-fixits.C b/gcc/testsuite/g++.dg/semicolon-fixits.C index a9cc783b1725..198e306c950d 100644 --- a/gcc/testsuite/g++.dg/semicolon-fixits.C +++ b/gcc/testsuite/g++.dg/semicolon-fixits.C @@ -1,3 +1,4 @@ +// { dg-do compile { target c++98_only } } /* { dg-options "-fdiagnostics-show-caret -Wpedantic" } */ /* Struct with extra semicolon. */ diff --git a/gcc/testsuite/g++.dg/warn/pedantic2.C b/gcc/testsuite/g++.dg/warn/pedantic2.C index 6c834162c1b6..37d77daaef3f 100644 --- a/gcc/testsuite/g++.dg/warn/pedantic2.C +++ b/gcc/testsuite/g++.dg/warn/pedantic2.C @@ -5,6 +5,6 @@ class foo foo() {}; void bar() {}; - foo(int) {};; // { dg-warning "extra" } - void bar(int) {};; // { dg-warning "extra" } + foo(int) {};; // { dg-warning "extra" "" { target c++98_only } } + void bar(int) {};; // { dg-warning "extra" "" { target c++98_only } } }; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse11.C b/gcc/testsuite/g++.old-deja/g++.jason/parse11.C index 40864c108ba0..157a9c46287d 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/parse11.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse11.C @@ -3,7 +3,7 @@ class aClass { - ; // { dg-error "" } missing declaration + ; // { dg-error "" "" { target c++98_only } } missing declaration private: - ; // { dg-error "" } missing declaration + ; // { dg-error "" "" { target c++98_only } } missing declaration };
reply other threads:[~2024-02-13 23:08 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240213230848.B85223857BA3@sourceware.org \ --to=mpolacek@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).