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

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 4 14:41:53 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++"'}}
----------------
a-tarasyuk wrote:

@MitalAshok Thanks for the feedback. I've added [linkage3.cpp](https://github.com/llvm/llvm-project/pull/101853/files#diff-dc2bba9678021106302e8711c2140ad1e575de50b157537e64b37621e97b9ec9) to cover this case.

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


More information about the cfe-commits mailing list