================ @@ -8052,10 +8061,7 @@ NamedDecl *Sema::ActOnVariableDeclarator( } // Special handling of variable named 'main'. - if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo()->isStr("main") && - NewVD->getDeclContext()->getRedeclContext()->isTranslationUnit() && - !getLangOpts().Freestanding && !NewVD->getDescribedVarTemplate()) { - + if (!getLangOpts().Freestanding && isMainVar(Name, NewVD)) { // C++ [basic.start.main]p3 // A program that declares a variable main at global scope is ill-formed. ---------------- MitalAshok wrote:
```suggestion // C++ [basic.start.main]p3: // A program that declares // - a variable main at global scope, or // - an entity named main with C language linkage (in any namespace) // is ill-formed. ``` To facilitate the diagnostic showing whether its a global variable or a C linkage variable, you could make `isMainVar` return an enum like `IMV_NotMain, IMV_GlobalMain, IMV_CLinkageMain`. Or you could inline the `isMainVar` function into here again since there would be three options now. This quote from the standard should be good enough documentation https://github.com/llvm/llvm-project/pull/101853 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits