[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 Jul 14 13:49:07 PDT 2025
================
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify %s
+
+// expected-error at +1{{'clang::sycl_external' attribute only applies to functions}}
+[[clang::sycl_external]] int a;
+
+
+// expected-error at +2{{'clang::sycl_external' attribute only applies to functions}}
+struct s {
+[[clang::sycl_external]] int b;
+};
+
+// expected-error at +1{{'clang::sycl_external' attribute takes no arguments}}
+[[clang::sycl_external(3)]] void bar() {}
+
+// 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:
I think those are useful to ensure that a diagnostic of some kind is issued. Ideally, I think the diagnostic would be something along the lines of "does not take an argument" since there is no defined argument syntax. I don't think it is worth trying to do better than the "expected expression" error though. The fact that some code some where is trying to parse arguments here is a separate and out-of-scope issue as far as I'm concerned.
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list