[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
Mital Ashok via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 4 02:57:47 PDT 2024
================
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s
+
+namespace c {
+ extern "C" void main(); // expected-error {{invalid linkage specification 'extern "C"'}}
+}
+extern "C" {
+ int main(); // expected-error {{invalid linkage specification 'extern "C"'}}
+}
+extern "C" int main(); // expected-error {{invalid linkage specification 'extern "C"'}}
+extern "C" struct A { int main(); }; // ok
+
+namespace cpp {
+ extern "C++" int main(); // expected-error {{invalid linkage specification 'extern "C++"'}}
----------------
MitalAshok wrote:
This one is allowed, https://eel.is/c++draft/basic.start.main#3.4 only disallows `extern "C"` `main`. If you are implementing that, could you add tests for functions (`extern "C" { int main(); }`) and variables (`extern "C" { void* main; }`) named `main`?
https://github.com/llvm/llvm-project/pull/101853
More information about the cfe-commits
mailing list