public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: "Arsen Arsenović" <arsen@aarsen.me>,
	"Jonathan Wakely" <jwakely.gcc@gmail.com>,
	gcc-patches@gcc.gnu.org
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>,
	Jakub Jelinek <jakub@redhat.com>,
	"Joseph S. Myers" <joseph@codesourcery.com>
Subject: Re: Handling of main() function for freestanding
Date: Thu, 13 Oct 2022 17:16:02 -0400	[thread overview]
Message-ID: <5b636835-20af-2372-75d2-92e31a3393ed@redhat.com> (raw)
In-Reply-To: <4964626.imyG0pze7u@bstg>

On 10/13/22 16:14, Arsen Arsenović wrote:
> On Thursday, 13 October 2022 19:24:41 CEST Jason Merrill wrote:
>> I was arguing that we don't need the new flag; there shouldn't be any
>> need to turn it off.
> At the time, I opted to go with a more conservative route; I haven't
> been around enough to have very strong opinions ;)  I certainly can't
> think of a way always adding a return can go wrong, but figured someone,
> somehow, might rely on this behavior.  Removed the flag and tested on
> x86_64-pc-linux-gnu, v3 attached.

Thanks!

> FWIW, there's precedent for treating main specially regardless of
> flag_hosted (e.g. it's always marked extern "C" in the C++ frontend,
> AFAICT).
> 
> -#define DECL_MAIN_P(NODE)				\
> +#define DECL_MAIN_FREESTANDING_P(NODE)			\
>     (DECL_EXTERN_C_FUNCTION_P (NODE)			\
>      && DECL_NAME (NODE) != NULL_TREE			\
> -    && MAIN_NAME_P (DECL_NAME (NODE))			\
> -    && flag_hosted)
> +    && MAIN_NAME_P (DECL_NAME (NODE)))
> +
> +/* Nonzero iff NODE is a declaration for `main', and we are hosted. */
> +#define DECL_MAIN_P(NODE) (DECL_MAIN_FREESTANDING_P(NODE) && flag_hosted)

I liked in the previous version that you checked the return type of main 
when !flag_hosted, here and in c_missing_noreturn_ok_p.  Let's bring 
that back.

Jason


  reply	other threads:[~2022-10-13 21:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28 20:15 Jonathan Wakely
2022-09-29  6:00 ` Richard Biener
2022-09-29  7:12   ` Jakub Jelinek
2022-09-29  9:21     ` Jonathan Wakely
2022-10-04 22:25 ` Jason Merrill
2022-10-04 23:28   ` Joel Sherrill
2022-10-07 11:30   ` Jonathan Wakely
2022-10-07 13:51     ` Jason Merrill
2022-10-07 13:53       ` Jakub Jelinek
2022-10-13 17:03       ` Arsen Arsenović
2022-10-13 17:10         ` Jakub Jelinek
2022-10-13 17:26           ` Arsen Arsenović
2022-10-13 17:24         ` Jason Merrill
2022-10-13 20:14           ` Arsen Arsenović
2022-10-13 21:16             ` Jason Merrill [this message]
2022-10-14 10:04               ` Arsen Arsenović
2022-10-14 15:17                 ` Jason Merrill
2022-10-21 10:33                 ` Ping (c,c++): " Arsen Arsenović
2022-10-21 21:02                   ` Joseph Myers
2022-10-23 11:54                     ` Arsen Arsenović
2022-10-24 13:46                       ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5b636835-20af-2372-75d2-92e31a3393ed@redhat.com \
    --to=jason@redhat.com \
    --cc=arsen@aarsen.me \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=jwakely.gcc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).