[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 15:01:38 PDT 2025


================
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// expected-warning at +1{{'clang::sycl_external' attribute ignored}}
+[[clang::sycl_external]] void bar() {}
+
+// expected-warning at +1{{'clang::sycl_external' attribute ignored}}
+[[clang::sycl_external]] int a;
+
+// expected-warning at +2{{'clang::sycl_external' attribute ignored}}
+namespace not_sycl {
+[[clang::sycl_external]] void foo() {}
+}
----------------
tahonermann wrote:

I don't think the namespace scoped example adds anything here, but I think it would be good to exercise a function template.
```suggestion
// expected-warning at +2{{'clang::sycl_external' attribute ignored}}
template<typename>
[[clang::sycl_external]] void ft(T) {}
template void ft(int);
```

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


More information about the cfe-commits mailing list