From: Nathan Sidwell <nathan@acm.org>
To: Jakub Jelinek <jakub@redhat.com>, Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [C++ PATCH] Avoid -Wreturn-type warnings if a switch has default label, no breaks inside of it, but is followed by a break (PR sanitizer/81275)
Date: Mon, 27 Nov 2017 12:44:00 -0000 [thread overview]
Message-ID: <c753fe8e-fcf1-1bbf-6a96-51455bd363e2@acm.org> (raw)
In-Reply-To: <20171124215953.GE14653@tucnak>
On 11/24/2017 04:59 PM, Jakub Jelinek wrote:
> Hi!
>
> The testcase below has a useless break; that causes a bogus -Wreturn-type
> warning. The C++ FE already has code to avoid adding a BREAK_STMT
> after a return or similar sequence that is known not to return.
> The following patch extends block_may_fallthrough to also return false
> for SWITCH_STMTs that can't fall through.
>
> Those are ones with non-empty body where the whole body can't fallthrough,
> additionally they need to have a default: case label (or cover the whole
> range of values, but that is not what this patch can compute, that would
> be too big duplication of the gimplification processing) and no BREAK_STMT.
>
> For the default: case label we need to look in all SWITCH_BODY children
> except for nested SWITCH_STMTs, for BREAK_STMTs also not in
> {FOR,DO,WHILE}_BODY.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2017-11-24 Jakub Jelinek <jakub@redhat.com>
>
> PR sanitizer/81275
> * cp-objcp-common.c (struct find_default_and_break_s): New type.
> (find_default_and_break): New function.
> (cxx_block_may_fallthru): Return false for SWITCH_STMT which
> contains no BREAK_STMTs and contains a default: CASE_LABEL_EXPR.
>
> * g++.dg/warn/pr81275.C: New test.
ok
--
Nathan Sidwell
prev parent reply other threads:[~2017-11-27 12:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-25 0:37 Jakub Jelinek
2017-11-25 10:16 ` Jakub Jelinek
2017-11-26 9:05 ` Jakub Jelinek
2017-11-27 13:39 ` Nathan Sidwell
2017-11-27 14:10 ` Jakub Jelinek
2017-11-28 9:14 ` [C++ PATCH] Avoid -Wreturn-type warnings if a switch has default label, no breaks inside of it, but is followed by a break (PR sanitizer/81275, take 2) Jakub Jelinek
2017-11-28 11:58 ` Nathan Sidwell
2017-11-27 12:49 ` [C++ PATCH] Avoid -Wreturn-type warnings if a switch has default label, no breaks inside of it, but is followed by a break (PR sanitizer/81275) Nathan Sidwell
2017-11-27 12:44 ` Nathan Sidwell [this message]
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=c753fe8e-fcf1-1bbf-6a96-51455bd363e2@acm.org \
--to=nathan@acm.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=jason@redhat.com \
/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: link
Be 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).