================
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown \
+// RUN:   -disable-llvm-passes -emit-llvm -verify %s -o - | FileCheck %s
+
+// This test checks that the sycl_external attribute is ignored for variadic
+// functions; no device code is emitted for such functions.
+
+// expected-warning@+1{{'clang::sycl_external' attribute ignored; a variadic 
function cannot be called from device code}}
+[[clang::sycl_external]] int variadic(int n, ...) { return n; }
+// CHECK-NOT: @_Z8variadiciz
+
+int reachedFromVariadicOnly() { return 1; }
+// CHECK-NOT: @_Z23reachedFromVariadicOnlyv
+
+// expected-warning@+1{{'clang::sycl_external' attribute ignored; a variadic 
function cannot be called from device code}}
+[[clang::sycl_external]] int variadicCaller(int n, ...) {
+  return reachedFromVariadicOnly();
+}
+// CHECK-NOT: @_Z14variadicCalleriz
+
+// CHECK: define dso_local spir_func noundef i32 @_Z11nonVariadici
+[[clang::sycl_external]] int nonVariadic(int n) { return n; }
----------------
tahonermann wrote:

Another good test would be to validate that a variadic function that is 
declared `[[clang::sycl_external]]` but not defined results in an error if the 
attribute is ignored and the function is ODR-used. This might have to go in a 
different test file since an error would prevent LLVM IR from being generated 
thereby breaking the other tests.

```
[[clang::sycl_external]] void undefinedVariadicFnTest(int, ...);
[[clang::sycl_external]] void useUndefinedIgnoredVariadicFn() {
  (void)&undefinedVariadicFnTest; // error: SYCL kernel cannot call an 
undefined function without SYCL_EXTERNAL attribute
}
```

Though, hmm, it seems that we are currently missing that diagnostic upstream so 
this might have to come with a FIXME comment for now.

https://github.com/llvm/llvm-project/pull/216393
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to