| 1 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only -fsycl-is-device -verify %s |
| 2 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 -fsyntax-only -fsycl-is-device -verify %s |
| 3 |
|
| 4 |
// These tests validate parsing of the sycl_kernel_entry_point argument list |
| 5 |
// and that the single argument names a type. |
| 6 |
|
| 7 |
// Templates used to exercise class template specializations. |
| 8 |
template<int> struct ST; // #ST-decl |
| 9 |
template<int N> using TTA = ST<N>; // #TTA-decl |
| 10 |
|
| 11 |
|
| 12 |
//////////////////////////////////////////////////////////////////////////////// |
| 13 |
// Valid declarations. |
| 14 |
//////////////////////////////////////////////////////////////////////////////// |
| 15 |
|
| 16 |
struct S1; |
| 17 |
[[clang::sycl_kernel_entry_point(S1)]] void ok1(); |
| 18 |
|
| 19 |
typedef struct {} TA2; |
| 20 |
[[clang::sycl_kernel_entry_point(TA2)]] void ok2(); |
| 21 |
|
| 22 |
using TA3 = struct {}; |
| 23 |
[[clang::sycl_kernel_entry_point(TA3)]] void ok3(); |
| 24 |
|
| 25 |
[[clang::sycl_kernel_entry_point(ST<4>)]] void ok4(); |
| 26 |
|
| 27 |
[[clang::sycl_kernel_entry_point(TTA<5>)]] void ok5(); |
| 28 |
|
| 29 |
namespace NS6 { |
| 30 |
struct NSS; |
| 31 |
} |
| 32 |
[[clang::sycl_kernel_entry_point(NS6::NSS)]] void ok6(); |
| 33 |
|
| 34 |
namespace { |
| 35 |
struct UNSS7; |
| 36 |
} |
| 37 |
[[clang::sycl_kernel_entry_point(UNSS7)]] void ok7(); |
| 38 |
|
| 39 |
struct {} s; |
| 40 |
[[clang::sycl_kernel_entry_point(decltype(s))]] void ok8(); |
| 41 |
|
| 42 |
template<typename KN> |
| 43 |
[[clang::sycl_kernel_entry_point(KN)]] void ok9(); |
| 44 |
void test_ok9() { |
| 45 |
ok9<struct LS1>(); |
| 46 |
} |
| 47 |
|
| 48 |
template<int, typename KN> |
| 49 |
[[clang::sycl_kernel_entry_point(KN)]] void ok10(); |
| 50 |
void test_ok10() { |
| 51 |
ok10<1, struct LS2>(); |
| 52 |
} |
| 53 |
|
| 54 |
namespace NS11 { |
| 55 |
struct NSS; |
| 56 |
} |
| 57 |
template<typename T> |
| 58 |
[[clang::sycl_kernel_entry_point(T)]] void ok11() {} |
| 59 |
template<> |
| 60 |
[[clang::sycl_kernel_entry_point(NS11::NSS)]] void ok11<NS11::NSS>() {} |
| 61 |
|
| 62 |
struct S12; |
| 63 |
[[clang::sycl_kernel_entry_point(S12)]] void ok12(); |
| 64 |
[[clang::sycl_kernel_entry_point(S12)]] void ok12() {} |
| 65 |
|
| 66 |
template<typename T> |
| 67 |
[[clang::sycl_kernel_entry_point(T)]] void ok13(T k); |
| 68 |
void test_ok13() { |
| 69 |
ok13([]{}); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
//////////////////////////////////////////////////////////////////////////////// |
| 74 |
// Invalid declarations. |
| 75 |
//////////////////////////////////////////////////////////////////////////////// |
| 76 |
|
| 77 |
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute takes one argument}} |
| 78 |
[[clang::sycl_kernel_entry_point]] void bad1(); |
| 79 |
|
| 80 |
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute takes one argument}} |
| 81 |
[[clang::sycl_kernel_entry_point()]] void bad2(); |
| 82 |
|
| 83 |
struct B3; |
| 84 |
// expected-error@+2 {{expected ')'}} |
| 85 |
// expected-error@+1 {{expected ']'}} |
| 86 |
[[clang::sycl_kernel_entry_point(B3,)]] void bad3(); |
| 87 |
|
| 88 |
struct B4; |
| 89 |
// expected-error@+3 {{expected ')'}} |
| 90 |
// expected-error@+2 {{expected ','}} |
| 91 |
// expected-warning@+1 {{unknown attribute 'X' ignored}} |
| 92 |
[[clang::sycl_kernel_entry_point(B4, X)]] void bad4(); |
| 93 |
|
| 94 |
// expected-error@+1 {{expected a type}} |
| 95 |
[[clang::sycl_kernel_entry_point(1)]] void bad5(); |
| 96 |
|
| 97 |
void f6(); |
| 98 |
// expected-error@+1 {{unknown type name 'f6'}} |
| 99 |
[[clang::sycl_kernel_entry_point(f6)]] void bad6(); |
| 100 |
|
| 101 |
// expected-error@+2 {{use of class template 'ST' requires template arguments; argument deduction not allowed here}} |
| 102 |
// expected-note@#ST-decl {{template is declared here}} |
| 103 |
[[clang::sycl_kernel_entry_point(ST)]] void bad7(); |
| 104 |
|
| 105 |
// expected-error@+2 {{use of alias template 'TTA' requires template arguments; argument deduction not allowed here}} |
| 106 |
// expected-note@#TTA-decl {{template is declared here}} |
| 107 |
[[clang::sycl_kernel_entry_point(TTA)]] void bad8(); |
| 108 |
|
| 109 |
enum { |
| 110 |
e9 |
| 111 |
}; |
| 112 |
// expected-error@+1 {{unknown type name 'e9'}} |
| 113 |
[[clang::sycl_kernel_entry_point(e9)]] void bad9(); |
| 114 |
|
| 115 |
#if __cplusplus >= 202002L |
| 116 |
template<typename> concept C = true; |
| 117 |
// expected-error@+1 {{expected a type}} |
| 118 |
[[clang::sycl_kernel_entry_point(C)]] void bad10(); |
| 119 |
|
| 120 |
// expected-error@+1 {{expected a type}} |
| 121 |
[[clang::sycl_kernel_entry_point(C<int>)]] void bad11(); |
| 122 |
#endif |