public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>,
	Richard Biener <rguenther@suse.de>,
	Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix up -Wreturn-type (PR c++/83045)
Date: Tue, 21 Nov 2017 17:29:00 -0000	[thread overview]
Message-ID: <62fa65f6-8e31-921e-00e4-6aac34eee17c@redhat.com> (raw)
In-Reply-To: <20171121135232.GW14653@tucnak>

On 11/21/2017 06:52 AM, Jakub Jelinek wrote:
> Hi!
> 
> The C++ FE now emits __builtin_unreachable () with BUILTINS_LOCATION
> on spots that return from functions/methods returning non-void without
> proper return.  This breaks the -Wreturn-type warning, because we then
> don't see any return stmt without argument on the edges to exit, instead
> we see those __builtin_unreachable () calls at the end of blocks without
> successors.
> 
> I wonder if the C++ FE addition of __builtin_unreachable () shouldn't be
> done only if (optimize).
> 
> Anyway, this patch tweaks tree-cfg.c so that it recognizes those
> __builtin_unreachable () calls and reports the -Wreturn-type warning
> in those cases too (warning in the FE would be too early, we need to
> optimize away unreachable code).
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> The patch regresses g++.dg/gomp/declare-simd-1.C, but given that it revealed
> a real bug, I'm not trying to work around it in the patch and will fix it up
> incrementally instead.
> 
> 2017-11-21  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c++/83045
> 	* tree-cfg.c (pass_warn_function_return::execute): Formatting fix.
> 	Also warn if seen __builtin_unreachable () call with BUILTINS_LOCATION.
> 	Use LOCATION_LOCUS when comparing against UNKNOWN_LOCATION.
> 
> 	* c-c++-common/pr61405.c (fn0, fn1): Add return stmts.
> 	* c-c++-common/Wlogical-op-2.c (fn): Likewise.
> 	* g++.dg/debug/pr53466.C: Add -Wno-return-type to dg-options.
> 	* g++.dg/opt/combine.C: Likewise.
> 	* g++.dg/ubsan/return-3.C: Likewise.
> 	* g++.dg/pr59445.C: Likewise.
> 	* g++.dg/pr49847.C: Likewise.
> 	* g++.dg/ipa/pr61800.C: Likewise.
> 	* g++.dg/ipa/pr63470.C: Likewise.
> 	* g++.dg/ipa/pr68672-1.C: Likewise.
> 	* g++.dg/pr58438.C: Likewise.
> 	* g++.dg/torture/pr59265.C: Likewise.
> 	* g++.dg/tree-ssa/ssa-dse-2.C: Likewise.
> 	* g++.old-deja/g++.eh/catch13.C: Likewise.
> 	* g++.old-deja/g++.eh/crash1.C: Likewise.
> 	* g++.dg/tm/pr60004.C: Expect -Wreturn-type warning.
> 	* g++.dg/torture/pr55740.C: Likewise.
> 	* g++.dg/torture/pr43257.C: Likewise.
> 	* g++.dg/torture/pr64280.C: Likewise.
> 	* g++.dg/torture/pr54684.C: Likewise.
> 	* g++.dg/torture/pr56694.C: Likewise.
> 	* g++.dg/torture/pr68470.C: Likewise.
> 	* g++.dg/torture/pr60648.C: Likewise.
> 	* g++.dg/torture/pr71281.C: Likewise.
> 	* g++.dg/torture/pr52772.C: Add -Wno-return-type dg-additional-options.
> 	* g++.dg/torture/pr64669.C: Likewise.
> 	* g++.dg/torture/pr58369.C: Likewise.
> 	* g++.dg/torture/pr33627.C: Likewise.
> 	* g++.dg/torture/predcom-1.C: Add
> 	#pragma GCC diagnostic ignored "-Wreturn-type".
> 	* g++.dg/lto/20090221_0.C: Likewise.
> 	* g++.dg/lto/20091026-1_1.C: Likewise.
> 	* g++.dg/lto/pr54625-1_1.C: Likewise.
> 	* g++.dg/warn/pr83045.C: New test.
OK.
jeff

  reply	other threads:[~2017-11-21 17:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 13:57 Jakub Jelinek
2017-11-21 17:29 ` Jeff Law [this message]
2017-11-22 16:49   ` Christophe Lyon

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=62fa65f6-8e31-921e-00e4-6aac34eee17c@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.com \
    --cc=rguenther@suse.de \
    /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).