[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
Mon Aug 5 01:28:00 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;
+}
----------------
MitalAshok wrote:
Does this need a separate member function? It seems like this would be good as a static helper function
https://github.com/llvm/llvm-project/pull/101853
More information about the cfe-commits
mailing list