================ @@ -851,6 +851,21 @@ Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, CurContext->addDecl(D); PushDeclContext(S, D); + if (getLangOpts().HLSL) { + // exported functions cannot be in an unnamed namespace + for (const DeclContext *DC = CurContext; DC; DC = DC->getLexicalParent()) { + if (const auto *ND = dyn_cast<NamespaceDecl>(DC)) { + if (ND->isAnonymousNamespace()) { + Diag(ExportLoc, diag::err_export_within_anonymous_namespace); + Diag(ND->getLocation(), diag::note_anonymous_namespace); + D->setInvalidDecl(); + return D; + } + } + } + return D; + } ---------------- hekota wrote:
Ok. I was debating whether to wrap all the other paths in `!getLangOpts().HLSL` or duplicate this one part and early exit. https://github.com/llvm/llvm-project/pull/96823 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits