public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103597] [12 Regression] False -Wimplicit-fallthrough= involving macro since r12-5638-ga3e75c1491cd2d50 Date: Tue, 07 Dec 2021 12:09:29 +0000 [thread overview] Message-ID: <bug-103597-4-OYrG2vuMAG@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103597-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103597 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |mpolacek at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- -Wimplicit-fallthrough is performed on the freshly gimplified IL, so cxx_block_may_fallthru is irrelevant to it. And so it sees switch (n) <default: <D.1987>, case 0: <D.1980>, case 1: <D.1981>> <D.1980>: if (1 != 0) goto <D.1984>; else goto <D.1985>; <D.1984>: D.1986 = 0; // predicted unlikely by early return (on trees) predictor. return D.1986; <D.1985>: <D.1981>: D.1986 = 1; return D.1986; <D.1987>: D.1986 = 2; return D.1986; where it sees that <D.1985>: falls through to <D.1981>: aka case 1:, and because this is done before cfg is created, we can't cheaply go back and see that D.1985 is only reachable from else of if (1). What we could if we have a spare bit on LABEL_DECL or GIMPLE_LABEL is do roughly what the C++ FE did previously in gimplify_cond_expr, but not through actually not emitting that cond, but by setting a flag on the LABEL_DECL or GIMPLE_LABEL that for the purposes of -Wimplicit-fallthrough warning we would consider unreachable and set it on labels for COND_EXPR with integer_nonzerop condition if !TREE_OPERANDS (expr, 2) || !TREE_SIDE_EFFECTS (TREE_OPERANDS (expr, 2)) on the label_false label and if integer_zerop condition and if !TREE_OPERANDS (expr, 1) || !TREE_SIDE_EFFECTS (TREE_OPERANDS (expr, 1)) on the label_true label. Perhaps only do that for the freshly created artificial labels though? After gimplification of the COND_EXPR this is harder because we could have if (1) { whatever; } else { ...; lab: ... } and goto lab; from somewhere etc. Unfortunately I'm not familiar enough with the -Wimplicit-fallthrough code, so I can help with setting a flag in gimplify_cond_expr for labels that should be ignored (i.e. we should act as if they weren't there, so when walking back look at what is before them etc.). Marek, could you please have a look?
next prev parent reply other threads:[~2021-12-07 12:09 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-07 8:16 [Bug c++/103597] New: False -Wimplicit-fallthrough= involving macro sbergman at redhat dot com 2021-12-07 8:29 ` [Bug c++/103597] [12 Regression] False -Wimplicit-fallthrough= involving macro since r12-5638-ga3e75c1491cd2d50 marxin at gcc dot gnu.org 2021-12-07 11:24 ` jakub at gcc dot gnu.org 2021-12-07 11:33 ` pinskia at gcc dot gnu.org 2021-12-07 12:09 ` jakub at gcc dot gnu.org [this message] 2021-12-07 18:53 ` jakub at gcc dot gnu.org 2021-12-07 19:07 ` mpolacek at gcc dot gnu.org 2022-03-28 16:05 ` [Bug debug/103597] " jason at gcc dot gnu.org 2022-03-29 0:09 ` [Bug middle-end/103597] " mpolacek at gcc dot gnu.org 2022-03-29 18:11 ` cvs-commit at gcc dot gnu.org 2022-03-29 18:12 ` 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-103597-4-OYrG2vuMAG@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).