[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p3 requirements (PR #101853)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 5 12:37:29 PDT 2024
================
@@ -12370,6 +12379,17 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) {
}
}
+bool Sema::CheckLinkageSpecification(DeclContext *DC, Decl *D) {
+ // [basic.start.main] p2
+ // The main function shall not be declared with a linkage-specification.
+ if (DC->isExternCContext()) {
+ Diag(D->getLocation(), diag::err_main_invalid_linkage_specification);
+ D->setInvalidDecl();
+ return true;
+ }
+ return false;
+}
----------------
a-tarasyuk wrote:
@Sirraide Thanks for the feedback. I've moved directly to `CheckMain`
https://github.com/llvm/llvm-project/pull/101853
More information about the cfe-commits
mailing list