This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Don't warn about missing noreturn for main
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: Don't warn about missing noreturn for main
- From: Robert Lipe <robertlipe at usa dot net>
- Date: Sat, 30 Dec 2000 16:15:07 -0600
- Cc: gcc-patches at gcc dot gnu dot org
- References: <u8hf3lps8a.fsf@gromit.rhein-neckar.de> <20001230151408.B3211@rjlhome.sco.com> <u8r92pobgd.fsf@gromit.rhein-neckar.de>
I wasn't confident about my suggestion, so I did it privately. The only
reason I noticed it was that I happened to be using a project in another
window that requires -ffreestanding for GCC. Andreas suggested moving
the discussion back to the list, so I have.
Language wizards, should this be suppressed in freestanding mode?
RJL
Andreas Jaeger wrote:
> >>>>> Robert Lipe writes:
>
> > Andreas Jaeger wrote:
> >> It's quite common to end main with exit (0) instead of a return
> >> value. But if you do this, and use -Wmissing-noreturn you get:
> >> t.c: In function `main':
> >> t.c:7: warning: function might be possible candidate for attribute `noreturn'
>
> > Should this apply only in hosted mode? In freestanding mode, main() has
> > no special significance...
>
> I haven't thought about this :-(. Please propose it on the list.
>
> But I could change this. Is flag_hosted the right variable to look
> at?
>
> In that case the patch should most properly look like (untested,
> edited by hand):
>
> if (warn_missing_noreturn
> && !TREE_THIS_VOLATILE (cfun->decl)
> + && !(flag_hosted && MAIN_NAME_P (DECL_NAME (cfun->decl)))
> && EXIT_BLOCK_PTR->pred == NULL)
>
> What do you think?
> Andreas
> --
> Andreas Jaeger
> SuSE Labs aj@suse.de
> private aj@arthur.inka.de
> http://www.suse.de/~aj