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


>>>>> "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

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