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