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

via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 6 05:47:22 PDT 2024


================
@@ -12210,7 +12215,22 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
   return Redeclaration;
 }
 
-void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) {
+void Sema::CheckMain(FunctionDecl *FD, const DeclSpec &DS) {
+  // [basic.start.main]p3
+  //    The main function shall not be declared with a linkage-specification.
+  if ((FD->isExternCContext() || FD->isExternCXXContext())) {
----------------
Sirraide wrote:

```suggestion
  if (FD->isExternCContext() || FD->isExternCXXContext()) {
```

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


More information about the cfe-commits mailing list