blob: 1e1a24ea8b5265a657eb20db1de972dfcb08c775 [file] [edit]
// RUN: %clang_cc1 -isystem %S/Inputs/ -fsycl-is-device -triple spirv64 -aux-triple x86_64-pc-windows-msvc -fsyntax-only -verify=expected,x86-host,aux %s
// RUN: %clang_cc1 -isystem %S/Inputs/ -fsycl-is-device -triple spirv64 -aux-triple x86_64-unknown-linux-gnu -fsyntax-only -verify=expected,x86-host,aux %s
// RUN: %clang_cc1 -isystem %S/Inputs/ -fsycl-is-device -triple spirv64 -aux-triple aarch64-unknown-linux-gnu -fsyntax-only -verify=expected,aux,no-x86-host %s
// RUN: %clang_cc1 -isystem %S/Inputs/ -fsycl-is-device -triple spirv64 -fsyntax-only -verify=expected,no-aux,no-x86-host %s
// Check that there is no error/warning emitted for cdecl functions compiled for
// SYCL device. Make sure variadic calls from within device code are diagnosed.
__inline __cdecl int printf(char const* const _Format, ...) { return 0; }
// expected-warning@+1 {{'clang::sycl_external' attribute ignored; a variadic function cannot be called from device code}}
[[clang::sycl_external]] int foo(int, ...) { return 0; }
__inline __cdecl int moo() { return 0; }
void bar() {
printf("hello\n");
}
// Accepted when the auxiliary host target supports the calling convention and
// diagnosed when neither the device nor the host does.
// no-x86-host-warning@+1 {{'regcall' calling convention is not supported for this target}}
void __attribute__((regcall)) rcall(int a, int b) {}
// no-x86-host-warning@+1 {{'vectorcall' calling convention is not supported for this target}}
void __attribute__((vectorcall)) vcall(float a, float b) {}
// Check some weird calling convention that is not supported even by x86_64 aux.
// no-aux-warning@+1 {{'__swiftasynccall__' calling convention is not supported for this target}}
void __attribute__((__swiftasynccall__)) g(void) {}
template<typename KN, typename...Args>
void sycl_kernel_launch(Args ...args) {}
template<typename KN, typename K>
[[clang::sycl_kernel_entry_point(KN)]]
__cdecl void sycl_entry_point(K k) {
k(); // expected-note {{called by}}
}
int main() {
//expected-error@+1 {{SYCL device code does not support variadic functions}}
sycl_entry_point<class kn>([]() { printf("world\n");
moo();
//expected-error@+1 {{SYCL device code does not support variadic functions}}
foo(1,2);
// Calls from device code are diagnosed when the device does not support
// the calling convention, even if the host does.
// x86-host-warning@+1 {{'regcall' calling convention is not supported for this target}}
rcall(1, 2);
// x86-host-warning@+1 {{'vectorcall' calling convention is not supported for this target}}
vcall(1.0f, 2.0f);
// aux-warning@+1 {{'swiftasynccall' calling convention is not supported for this target}}
g(); });
bar();
return 0;
}