[clang] [HLSL] Implement `export` keyword (PR #96823)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 27 14:34:18 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);
+      }
----------------
bogner wrote:

The export_within_export case looks like it's handled in ActOnStartExportDecl in C++ - is HLSL's behaviour different in that respect?

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


More information about the cfe-commits mailing list