From patchwork Tue Feb 13 22:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1898536 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZGOYYtT6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZGxH6pVVz23hT for ; Wed, 14 Feb 2024 09:59:47 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E6936385783C for ; Tue, 13 Feb 2024 22:59:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A74BC3857BAF for ; Tue, 13 Feb 2024 22:59:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A74BC3857BAF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A74BC3857BAF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707865162; cv=none; b=bUssZ5j5cnPgB2kD4ttQKjtxH6EpSr0IcVGUF3AxWFCgwvydULTXxdJYvw2ZqoiVXCi3AFrLTWHC6HRrdeNgyJEMuuIlspkjgmFeH5KxKlgoB00Zc6gHEil/XfEAOEbXxC+NOz7sQZ4J8DIgAehdwMBi+auoTC97wnPpF9yycOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707865162; c=relaxed/simple; bh=ovmMvGzoD7KMgKoLv4MYQHDUQzrSkA3XDzCQncqxk08=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xCSDmkMti1asZg8ZLQNdm3VcfJlfxqJ/w43jLM07gygZbXsMROKhYXjy2ZAS/hatv9IK0dG2nRtbzVvEFN6cJ8djvJcQ/nyHrvf7nPGO5EG9WwOLHDdDiulUVL4auYkR/vnr4zSebP8Wwfwu3hklK2Ay/JFKBXCr3kctS/rerhc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707865160; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JoVPVmE3ZgV71P/fFJj+3gIG+S79Wdtra4W/QIIVmsM=; b=ZGOYYtT6hnIM86wfGgnyL9Ro+rdzV2Ps2vMVuFvF2xqG71mgb/wysLONHoQ7AmuevNmD/G Wxx+nTwfBhrhC2QcyNVsMokg2iIhsRaXZmXlAj1afaVv5dFIsCd5isZNYoQcoVcOdRMciQ fqXtfBwzYe04OecMoXz1L0Csd5u4xxU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-VyHLu4boNGK7dvSztQB3Bw-1; Tue, 13 Feb 2024 17:59:19 -0500 X-MC-Unique: VyHLu4boNGK7dvSztQB3Bw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC19884AC60 for ; Tue, 13 Feb 2024 22:59:18 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.9.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A4BC2166B31; Tue, 13 Feb 2024 22:59:18 +0000 (UTC) From: Marek Polacek To: Jason Merrill , GCC Patches Subject: [PATCH] c++: adjust the extra ; warning [PR113760] Date: Tue, 13 Feb 2024 17:59:14 -0500 Message-ID: <20240213225914.85810-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? -- >8 -- 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. --- 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(-) create mode 100644 gcc/testsuite/g++.dg/DRs/dr1693-1.C create mode 100644 gcc/testsuite/g++.dg/DRs/dr1693-2.C base-commit: ab71fd7ac7a2307723117c796e7ae4d7e9711058 diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 68ab74d70b9..9d0914435fb 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 00000000000..ed27026109c --- /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 00000000000..c52259d4602 --- /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 a9cc783b172..198e306c950 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 6c834162c1b..37d77daaef3 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 40864c108ba..157a9c46287 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 };