================
@@ -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:

This test is curious in this source file since it doesn't involve a variadic 
function. I guess this is intended as a control; to verify that something else 
isn't preventing the other `SYCL_EXTERNAL` functions from being emitted? If so, 
I think a comment would be helpful.

```suggestion
// Check that non-variadic functions are emitted to ensure the lack
// of emission for the others is due to their being variadic functions.
[[clang::sycl_external]] int nonVariadic(int n) { return n; }
// CHECK: define dso_local spir_func noundef i32 @_Z11nonVariadici
```

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