[clang] [HLSL] Implement `export` keyword (PR #96823)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 27 18:25:34 PDT 2024
================
@@ -924,6 +939,23 @@ static bool checkExportedDeclContext(Sema &S, DeclContext *DC,
/// Check that it's valid to export \p D.
static bool checkExportedDecl(Sema &S, Decl *D, SourceLocation BlockStart) {
+ // HLSL: export declaration is valid only on functions
+ if (S.getLangOpts().HLSL) {
+ auto *FD = dyn_cast<FunctionDecl>(D);
+ if (!FD) {
+ if (auto *ED2 = dyn_cast<ExportDecl>(D)) {
+ S.Diag(ED2->getBeginLoc(), diag::err_export_within_export);
+ if (auto *ED1 = dyn_cast<ExportDecl>(D->getDeclContext()))
+ S.Diag(ED1->getBeginLoc(), diag::note_export);
+ }
----------------
hekota wrote:
Good catch!
https://github.com/llvm/llvm-project/pull/96823
More information about the cfe-commits
mailing list