[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 5 02:56:21 PDT 2024
================
@@ -990,6 +990,8 @@ def warn_main_redefined : Warning<"variable named 'main' with external linkage "
"has undefined behavior">, InGroup<Main>;
def ext_main_used : Extension<
"referring to 'main' within an expression is a Clang extension">, InGroup<Main>;
+def err_main_invalid_linkage_specification : ExtWarn<
+ "'main' cannot have linkage specification 'extern \"C\"'">, InGroup<Main>;
----------------
Sirraide wrote:
```suggestion
"'main' should not be extern \"C\"">, InGroup<Main>;
```
I think something like this would be better imo; I don’t like ‘cannot’ since we still accept the code, so it’s not technically correct that it *cannot* have a linkage specification (it can’t according to the standard, but only EDG currently diagnoses this, and even then it’s just a warning), it just really *shouldn’t*.
https://github.com/llvm/llvm-project/pull/101853
More information about the cfe-commits
mailing list