[clang] [Clang] fix crash by avoiding invalidation of extern main declaration during strictness checks (PR #104594)
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 16 08:19:03 PDT 2024
================
@@ -122,6 +119,26 @@ namespace ns2 {
extern "C++" void main() {} // ok
}
+#elif TEST14
+extern "C" {
+ int main(); // expected-warning {{'main' should not be 'extern "C"'}}
+}
+
+extern "C" int main(); // expected-warning {{'main' should not be 'extern "C"'}}
+
+#elif TEST15
+extern "C" __attribute__((visibility("default"))) __attribute__((weak))
----------------
alexfh wrote:
nit: This can be simplified a bit:
```
extern "C" __attribute__((visibility("default"))) __attribute__((weak))
int main();
unsigned long g() {
return reinterpret_cast<unsigned long>(&main);
}
```
https://gcc.godbolt.org/z/j5crjfebq
https://github.com/llvm/llvm-project/pull/104594
More information about the cfe-commits
mailing list