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
4 // These tests validate parsing of the sycl_kernel_entry_point argument list
5 // and that the single argument names a type.
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
12 ////////////////////////////////////////////////////////////////////////////////
13 // Valid declarations.
14 ////////////////////////////////////////////////////////////////////////////////
17 [[clang::sycl_kernel_entry_point(S1
)]] void ok1();
19 typedef struct {} TA2
;
20 [[clang::sycl_kernel_entry_point(TA2
)]] void ok2();
22 using TA3
= struct {};
23 [[clang::sycl_kernel_entry_point(TA3
)]] void ok3();
25 [[clang::sycl_kernel_entry_point(ST
<4>)]] void ok4();
27 [[clang::sycl_kernel_entry_point(TTA
<5>)]] void ok5();
32 [[clang::sycl_kernel_entry_point(NS6::NSS
)]] void ok6();
37 [[clang::sycl_kernel_entry_point(UNSS7
)]] void ok7();
40 [[clang::sycl_kernel_entry_point(decltype(s
))]] void ok8();
43 [[clang::sycl_kernel_entry_point(KN
)]] void ok9();
48 template<int, typename KN
>
49 [[clang::sycl_kernel_entry_point(KN
)]] void ok10();
51 ok10
<1, struct LS2
>();
58 [[clang::sycl_kernel_entry_point(T
)]] void ok11() {}
60 [[clang::sycl_kernel_entry_point(NS11::NSS
)]] void ok11
<NS11::NSS
>() {}
63 [[clang::sycl_kernel_entry_point(S12
)]] void ok12();
64 [[clang::sycl_kernel_entry_point(S12
)]] void ok12() {}
67 [[clang::sycl_kernel_entry_point(T
)]] void ok13(T k
);
73 ////////////////////////////////////////////////////////////////////////////////
74 // Invalid declarations.
75 ////////////////////////////////////////////////////////////////////////////////
77 // expected-error@+1 {{'sycl_kernel_entry_point' attribute takes one argument}}
78 [[clang::sycl_kernel_entry_point
]] void bad1();
80 // expected-error@+1 {{'sycl_kernel_entry_point' attribute takes one argument}}
81 [[clang::sycl_kernel_entry_point()]] void bad2();
84 // expected-error@+2 {{expected ')'}}
85 // expected-error@+1 {{expected ']'}}
86 [[clang::sycl_kernel_entry_point(B3
,)]] void bad3();
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();
94 // expected-error@+1 {{expected a type}}
95 [[clang::sycl_kernel_entry_point(1)]] void bad5();
98 // expected-error@+1 {{unknown type name 'f6'}}
99 [[clang::sycl_kernel_entry_point(f6
)]] void bad6();
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();
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();
112 // expected-error@+1 {{unknown type name 'e9'}}
113 [[clang::sycl_kernel_entry_point(e9
)]] void bad9();
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();
120 // expected-error@+1 {{expected a type}}
121 [[clang::sycl_kernel_entry_point(C
<int>)]] void bad11();
124 struct B12
; // #B12-decl
125 // FIXME: C++23 [temp.expl.spec]p12 states:
126 // FIXME: ... Similarly, attributes appearing in the declaration of a template
127 // FIXME: have no effect on an explicit specialization of that template.
128 // FIXME: Clang currently instantiates and propagates attributes from a function
129 // FIXME: template to its explicit specializations resulting in the following
130 // FIXME: spurious error.
131 // expected-error@+4 {{incomplete type 'B12' named in nested name specifier}}
132 // expected-note@+5 {{in instantiation of function template specialization 'bad12<B12>' requested here}}
133 // expected-note@#B12-decl {{forward declaration of 'B12'}}
135 [[clang::sycl_kernel_entry_point(typename
T::not_found
)]] void bad12() {}