public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.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, 24 Jan 2024 22:59:44 +0000 [thread overview] Message-ID: <bug-113582-4-pm8NU9jL3i@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113582-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113582 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org --- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Hack/fix: diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 3748ccd49ff..224d47f2f90 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -13093,7 +13093,11 @@ cp_parser_label_for_labeled_statement (cp_parser* parser, tree attributes) /* Anything else must be an ordinary label. */ label = finish_label_stmt (cp_parser_identifier (parser)); if (label && TREE_CODE (label) == LABEL_DECL) - FALLTHROUGH_LABEL_P (label) = fallthrough_p; + { + FALLTHROUGH_LABEL_P (label) = fallthrough_p; + if (!warning_enabled_at (input_location, OPT_Wunused_label)) + suppress_warning (label, OPT_Wunused_label); + } break; } diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 74013533b0f..b6686d8543f 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -18796,11 +18796,13 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl) case LABEL_EXPR: { tree decl = LABEL_EXPR_LABEL (t); - tree label; - - label = finish_label_stmt (DECL_NAME (decl)); + tree label = finish_label_stmt (DECL_NAME (decl)); if (TREE_CODE (label) == LABEL_DECL) - FALLTHROUGH_LABEL_P (label) = FALLTHROUGH_LABEL_P (decl); + { + FALLTHROUGH_LABEL_P (label) = FALLTHROUGH_LABEL_P (decl); + if (warning_suppressed_p (decl, OPT_Wunused_label)) + TREE_USED (label) = true; + } if (DECL_ATTRIBUTES (decl) != NULL_TREE) cplus_decl_attributes (&label, DECL_ATTRIBUTES (decl), 0); }
next prev parent reply other threads:[~2024-01-24 22:59 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-24 13:48 [Bug c++/113582] New: incorrect warning about " nmmm at nmmm dot nu 2024-01-24 14:31 ` [Bug c++/113582] " nmmm at nmmm dot nu 2024-01-24 21:13 ` mpolacek at gcc dot gnu.org 2024-01-24 21:19 ` [Bug c++/113582] incorrect warning about unused label with `pragma GCC diagnostic` around the " pinskia at gcc dot gnu.org 2024-01-24 22:59 ` mpolacek at gcc dot gnu.org [this message] 2024-01-24 23:01 ` mpolacek at gcc dot gnu.org 2024-01-30 16:12 ` mpolacek at gcc dot gnu.org 2024-05-08 16:22 ` cvs-commit at gcc dot gnu.org 2024-05-08 16:24 ` mpolacek at gcc dot gnu.org
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=bug-113582-4-pm8NU9jL3i@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).