|
| 1 | +// RUN: %clang_cc1 -triple spir64-unknown-linux-sycldevice -fms-extensions \ |
| 2 | +// RUN: -aux-triple x86_64-unknown-linux-gnu -fsycl-is-device -fsyntax-only \ |
| 3 | +// RUN: -DWARNCHECK %s -o /dev/null 2>&1 | FileCheck %s |
| 4 | +// check random triple aux-triple with sycl-device |
| 5 | + |
| 6 | +// RUN: %clang_cc1 -triple spir64-unknown-windows-sycldevice -fsyntax-only \ |
| 7 | +// RUN: -fms-extensions -DWARNCHECK %s -o /dev/null 2>&1 | FileCheck %s |
| 8 | +// check without -aux-triple but sycl-device |
| 9 | + |
| 10 | +// RUN: %clang_cc1 -triple spir64-unknown-windows-sycldevice -fsycl-is-device \ |
| 11 | +// RUN: -aux-triple x86_64-pc-windows-msvc -fms-extensions -fsyntax-only \ |
| 12 | +// RUN: -DWARNCHECK %s -o /dev/null 2>&1 | FileCheck %s --check-prefixes CHECKALL |
| 13 | +// check -aux-tripe without sycl-device |
| 14 | + |
| 15 | +// RUN: %clang_cc1 -triple spir64-unknown-windows-sycldevice -fsyntax-only \ |
| 16 | +// RUN: -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -fms-extensions \ |
| 17 | +// RUN: -verify %s |
| 18 | +// check error message when dllimport function gets called in sycl-kernel cdoe |
| 19 | + |
| 20 | +#if defined(WARNCHECK) |
| 21 | +// CHECK: warning: __declspec attribute 'dllexport' is not supported |
| 22 | +int __declspec(dllexport) foo(int a) { |
| 23 | + return a; |
| 24 | +} |
| 25 | + |
| 26 | +// CHECK: warning: __declspec attribute 'dllimport' is not supported |
| 27 | +int __declspec(dllimport) bar(); |
| 28 | + |
| 29 | + |
| 30 | +// CHECK: warning: unknown attribute 'dllimport' ignored |
| 31 | +int [[dllimport]]xoo(); |
| 32 | + |
| 33 | +// CHECKALL: warning: unknown attribute 'dllimport' ignored |
| 34 | +int zoo() __attribute__((dllimport)); |
| 35 | + |
| 36 | +#else |
| 37 | + |
| 38 | +// emit error if dllimport function is called in sycl kernel |
| 39 | +int __declspec(dllexport) foo(int a) { |
| 40 | + return a; |
| 41 | +} |
| 42 | +// expected-note@+1 {{'bar' declared here}} |
| 43 | +int __declspec(dllimport) bar(); |
| 44 | +// expected-note@+2 {{previous attribute is here}} |
| 45 | +// expected-note@+1 {{previous declaration is here}} |
| 46 | +int __declspec(dllimport) foobar(); |
| 47 | +int foobar() // expected-warning {{'foobar' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}} |
| 48 | +{ |
| 49 | + return 10; |
| 50 | +} |
| 51 | + |
| 52 | +template <typename name, typename Func> |
| 53 | +__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) { |
| 54 | + kernelFunc(); |
| 55 | +} |
| 56 | + |
| 57 | +int main() { |
| 58 | + foo(10); // expected-no-error |
| 59 | + bar(); // expected-no-error |
| 60 | + kernel_single_task<class fake_kernel>([]() { |
| 61 | + foo(10);// expected-no-error |
| 62 | + bar(); // expected-error {{SYCL kernel cannot call a dllimport function}} |
| 63 | + foobar(); // expected-no-error |
| 64 | + }); |
| 65 | + bar(); // expected-no-error |
| 66 | + return 0; |
| 67 | +} |
| 68 | +#endif |
0 commit comments