From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AECE338460B4; Wed, 8 May 2024 16:22:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AECE338460B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715185357; bh=fBN6bxpBHyix4keMqekQcaNNgHaA7yvCSWmN3uYIqpQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nmmcYBmqHHGb9hKSdG6mObQyedNiU1oMwK2/GazceF4tROe/igLHFhqT7i/uMSi4P csKKEsZ2eVbPBJykBfoggD13ALy5LcOdKzSrjt3N633HwKgk4oUR8oXXjvXEb6bjzg oP+S/LUWVYu2JNduTH+33IG8WhERcBIbUxALdkxs= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113582] incorrect warning about unused label with `pragma GCC diagnostic` around the unused label Date: Wed, 08 May 2024 16:22:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113582 --- Comment #7 from GCC Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:d9318caed3bbff8136d13e00dcfc020a59d10f78 commit r15-329-gd9318caed3bbff8136d13e00dcfc020a59d10f78 Author: Marek Polacek Date: Wed Jan 24 18:06:48 2024 -0500 c++: #pragma doesn't disable -Wunused-label [PR113582] The PR complains that void do_something(){ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-label" start:; #pragma GCC diagnostic pop } #1 doesn't work. That's because we warn_for_unused_label only while we're in finish_function, meaning we're at #1 where we're outside the #pragma region. We can use suppress_warning + warning_suppressed_p to fix this. Note that I'm not using TREE_USED. Propagating it in tsubst_stmt/LABEL_EXPR from decl to label would mean that we don't warn in do_something2, but I think we want the warning there: we're in a template and the goto is a discarded statement. PR c++/113582 gcc/c-family/ChangeLog: * c-warn.cc (warn_for_unused_label): Don't warn if -Wunused-lab= el has been suppressed for the label. gcc/cp/ChangeLog: * parser.cc (cp_parser_label_for_labeled_statement): suppress_warning if it's not enabled at input_location. * pt.cc (tsubst_stmt): Call copy_warning. gcc/testsuite/ChangeLog: * g++.dg/warn/Wunused-label-4.C: New test.=