[libcxx-commits] [clang] [libcxx] [clang] [modules] Implement P3618R0: Allow attaching main to the global module (PR #146461)
Ashwin Banwari via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 30 22:00:08 PDT 2025
================
@@ -12400,12 +12400,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
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() &&
- FD->getDeclContext()->getRedeclContext()->isTranslationUnit()))
- Diag(FD->getLocation(), diag::ext_main_invalid_linkage_specification)
- << FD->getLanguageLinkage();
+ // The main function shall not be declared with C linkage-specification.
+ if (FD->isExternCContext())
+ Diag(FD->getLocation(), diag::ext_main_invalid_linkage_specification);
----------------
ashwinbanwari wrote:
According to proposal, `extern "C"` for main is still ill-formed regardless if it is named module or not. On other hand, `extern "C++"` is allowed whether in named module or not.
https://github.com/llvm/llvm-project/pull/146461
More information about the libcxx-commits
mailing list