This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Don't warn about missing noreturn for main


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]