This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][RFC] Instrument function exit with __builtin_unreachable in C++.
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Liška <mliska at suse dot cz>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, gcc-patches at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>, Marek Polacek <polacek at redhat dot com>, Jonathan Wakely <jwakely at redhat dot com>
- Date: Wed, 15 Nov 2017 09:07:26 +0100
- Subject: Re: [PATCH][RFC] Instrument function exit with __builtin_unreachable in C++.
- Authentication-results: sourceware.org; auth=none
- References: <31ddd79e-1152-9dd9-663b-acd8d1bcd4ab@suse.cz> <99de094c-0e98-f2f2-39a9-a7394e0604ad@redhat.com> <0d484e7b-782b-7c4c-cdda-723efffe15a5@suse.cz> <3785116.x86eWSSaOg@polaris> <20171106173358.GU14653@tucnak> <806d7d62-1de5-128e-67e6-4b740c70d3b4@suse.cz>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Nov 07, 2017 at 11:08:58AM +0100, Martin Liška wrote:
> > Hasn't it enabled it also for any other FEs other than C family and Fortran?
> > Say jit, brig, go, lto?, ...
> > I think better would be to remove the initialization to -1 and revert the
> > fortran/options.c change, and instead use in the C family:
> > if (!global_options_set.x_warn_return_type)
> > warn_return_type = c_dialect_cxx ();
> >
> > Unless it for some reason doesn't work for -Wall or -W or similar.
> >
>
> Hello.
>
> Sorry for the inconvenience, however using Jakub's approach really does not work properly
> with -Wall.
If -Wall had an underlying variable, then we could use:
if (!global_options_set.x_warn_return_type
&& !global_options_set.x_warn_all)
warn_return_type = c_dialect_cxx ();
But we don't. Wonder if in addition to your patch or instead of it it
wouldn't be safer (especially for FEs added in the future) to:
/* If we see "return;" in some basic block, then we do reach the end
without returning a value. */
- else if (warn_return_type
+ else if (warn_return_type > 0
&& !TREE_NO_WARNING (fun->decl)
&& EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (fun)->preds) > 0
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fun->decl))))
in tree-cfg.c. That change is preapproved if it works, and your
patch if you want in addition to that is ok too.
Jakub