[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
Tue Jun 24 10:31:49 PDT 2025
================
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %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) {}
+
+// FIXME: The first declaration of a function is required to have the attribute.
+// The attribute may be optionally present on subsequent declarations
----------------
tahonermann wrote:
This diagnostic is pretty straight forward to implement. See `Sema::MergeFunctionDecl()` and the checks done for `CXX11NoReturnAttr` and `CarriesDependencyAttr`.
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list