[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


================
@@ -12879,6 +12879,15 @@ def err_sycl_special_type_num_init_method : Error<
   "types with 'sycl_special_class' attribute must have one and only one '__init' "
   "method defined">;
 
+// SYCL external attribute diagnostics
+def err_sycl_attribute_invalid_linkage : Error<
+  "'sycl_external' can only be applied to functions with external linkage">;
+def err_sycl_attribute_avoid_main : Error<
+  "'sycl_external' cannot be applied to the 'main' function">;
+def err_sycl_attribute_avoid_deleted_function
+    : Error<"'sycl_external' cannot be applied to an explicitly deleted "
+            "function">;
----------------
tahonermann wrote:

I suggest using "invalid" in place of "avoid" for consistency with other nearby diagnostics. Please keep the wrapping and indentation style consistent with nearby code.
```suggestion
def err_sycl_attribute_invalid_main : Error<
  "'sycl_external' cannot be applied to the 'main' function">;
def err_sycl_attribute_invalid_deleted_function : Error<
  "'sycl_external' cannot be applied to an explicitly deleted function">;
```

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


More information about the cfe-commits mailing list