[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)
Tom Honermann via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 11 17:50:44 PDT 2025
================
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsycl-is-device -std=c++20 -fsyntax-only -verify -DCPP20 %s
+// Semantic tests for sycl_external attribute
+
+[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}}
+static void func1() {}
+
+namespace {
+ [[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}}
+ void func2() {}
+
+ struct UnnX {};
+}
+
+[[clang::sycl_external]] // expected-error {{'sycl_external' can only be applied to functions with external linkage}}
+ void func4(UnnX) {}
+
----------------
tahonermann wrote:
Here is another case. DPC++ does diagnose this one. https://godbolt.org/z/9E9aPn6eq
```
namespace { struct S8 {}; }
template<typename>
void func8();
template<> [[clang::sycl_external]] void func8<S8>() {}
```
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list