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: aj at suse dot de
- Subject: Re: Don't warn about missing noreturn for main
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Sun, 31 Dec 2000 11:55:02 -0800
- Cc: gcc-patches at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <u8hf3lps8a.fsf@gromit.rhein-neckar.de>
>>>>> "Andreas" == Andreas Jaeger <aj@suse.de> writes:
Andreas> It's quite common to end main with exit (0) instead of a
Andreas> return value. But if you do this, and use
Andreas> -Wmissing-noreturn you get: t.c: In function `main':
Andreas> t.c:7: warning: function might be possible candidate for
Andreas> attribute `noreturn'
Andreas> Here's a patch (together with a corresponding testcase
Andreas> and documentation update) to suppress the warning. IMO
Andreas> there's no sense to warn about this for main.
Andreas> What do you think? Is it ok to install?
There is at least one technical problem with the patch:
- The test you propse isn't strict enough -- in lots of languages
things can be named `main' but be in a "namespace" so that they
are not *the* main function. In fact, in some languages the
global `main' might not be *the* `main'; checking
DECL_ASSEMBLER_NAME might be better, but then you get into
issues about leading `_', etc. What's needed here is a bit
that language front-ends set to indicate that a particular
function really is `main', or (probably better) a callback.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com