[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 14 09:42:39 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) {}
+
----------------
schittir 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>() {}
> ```
`template<> [[clang::sycl_external]] void func8<S8>() {} `line triggers a "'clang::sycl_external' attribute does not appear on the first declaration" diagnostic implemented in this PR
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list