[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
Mon Jun 16 07:01:07 PDT 2025


================
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s
+
+// expected-warning at +1{{'sycl_external' attribute only applies to functions}}
+[[clang::sycl_external]] int a;
+
+
+// expected-warning at +2{{'sycl_external' attribute only applies to functions}}
+struct s {
+[[clang::sycl_external]] int b;
+};
+
+// FIXME: The first declaration of a function is required to have the attribute.
+// The attribute may be optionally present on subsequent declarations
+int foo(int c);
+
+[[clang::sycl_external]] void foo();
----------------
tahonermann wrote:

The test file naming is inconsistent with naming of the test files for `sycl_kernel_entry_point`. The `-grammar.cpp` suffix is intended for use in exercising the syntax of the attribute itself, not what it appertains to. These tests are more appropriate for `sycl-external-attr.cpp` (or perhaps a `sycl-external-attr-appertainment.cpp`).

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


More information about the cfe-commits mailing list