[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 18 08:30:24 PDT 2025


================
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -fsycl-is-device -std=c++17 -fsyntax-only -verify -DCPP17 %s
+// RUN: %clang_cc1 -fsycl-is-device -std=c++20 -fsyntax-only -verify -DCPP20 %s
+
+// Semantic tests for the sycl_external attribute.
+
+// expected-error at +1{{'sycl_external' can only be applied to functions with external linkage}}
+[[clang::sycl_external]]
+static void func1() {}
+
+// expected-error at +2{{'sycl_external' can only be applied to functions with external linkage}}
+namespace {
+  [[clang::sycl_external]]
+  void func2() {}
+
+  struct UnnX {};
+}
+
+// expected-error at +2{{'sycl_external' can only be applied to functions with external linkage}}
+namespace { struct S4 {}; }
+[[clang::sycl_external]] void func4(S4) {}
+
+// FIXME: This case is currently being diagnosed as an error because clang implements
+// default inheritance of attribute and explicit instantiation declaration names the
+// symbol that causes the instantiated specialization to have internal linkage.
----------------
schittir wrote:

I see. Thank you for clarifying it with the text from spec for the other case. 

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


More information about the cfe-commits mailing list