[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p3 requirements (PR #101853)

Mital Ashok via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 6 09:26:36 PDT 2024


================
@@ -61,6 +64,64 @@ int q(void)
 // expected-no-diagnostics
 int main;
 
+#elif TEST11
+extern "C" {
+  namespace Y {
+    int main; // expected-error {{main cannot be declared as global variable}}
----------------
MitalAshok wrote:

These diagnostics could be similar to: https://github.com/llvm/llvm-project/blob/150bf637baad2ba4df6369600b65d897ed9b31a7/clang/include/clang/Basic/DiagnosticSemaKinds.td#L6083-L6087

So `main cannot be declared as a variable %select{in the global scope|with C language linkage}0`.

https://github.com/llvm/llvm-project/pull/101853


More information about the cfe-commits mailing list