2
2
//
3
3
// Ensure that the SYCL diagnostics that are typically deferred are correctly emitted.
4
4
5
+ namespace std {
6
+ class type_info ;
7
+ typedef __typeof__ (sizeof (int )) size_t;
8
+ } // namespace std
9
+
5
10
// testing that the deferred diagnostics work in conjunction with the SYCL namespaces.
6
11
inline namespace cl {
7
12
namespace sycl {
8
13
9
14
template <typename name, typename Func>
10
15
__attribute__ ((sycl_kernel)) void kernel_single_task (Func kernelFunc) {
11
- // expected-note@+1 2 {{called by 'kernel_single_task<AName, (lambda}}
16
+ // expected-note@+1 3 {{called by 'kernel_single_task<AName, (lambda}}
12
17
kernelFunc ();
13
18
}
14
19
@@ -18,11 +23,12 @@ __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
18
23
// variadic functions from SYCL kernels emit a deferred diagnostic
19
24
void variadic (int , ...) {}
20
25
26
+ // there are more types like this checked in sycl-restrict.cpp
21
27
int calledFromKernel (int a) {
22
28
// expected-error@+1 {{zero-length arrays are not permitted in C++}}
23
29
int MalArray[0 ];
24
30
25
- // expected-error@+1 {{__float128 is not supported on this target}}
31
+ // expected-error@+1 {{' __float128' is not supported on this target}}
26
32
__float128 malFloat = 40 ;
27
33
28
34
// expected-error@+1 {{SYCL kernel cannot call a variadic function}}
@@ -31,21 +37,102 @@ int calledFromKernel(int a) {
31
37
return a + 20 ;
32
38
}
33
39
40
+ // defines (early and late)
41
+ #define floatDef __float128
42
+ #define int128Def __int128
43
+ #define int128tDef __int128_t
44
+ #define intDef int
45
+
46
+ // typedefs (late )
47
+ typedef const __uint128_t megeType;
48
+ typedef const __float128 trickyFloatType;
49
+ typedef const __int128 tricky128Type;
50
+
51
+ // templated type (late)
52
+ template <typename T>
53
+ T bar () { return T (); };
54
+
55
+ // false positive. early incorrectly catches
56
+ template <typename t>
57
+ void foo (){};
58
+
34
59
// template used to specialize a function that contains a lambda that should
35
60
// result in a deferred diagnostic being emitted.
36
- // HOWEVER, this is not working presently.
37
- // TODO: re-test after new deferred diagnostic system is merged.
38
- // restore the "FIX!!" tests below
39
61
40
62
template <typename T>
41
63
void setup_sycl_operation (const T VA[]) {
42
64
43
65
cl::sycl::kernel_single_task<class AName >([]() {
44
- // FIX!! xpected-error@+1 {{zero-length arrays are not permitted in C++}}
45
- int OverlookedBadArray[0 ];
46
-
47
- // FIX!! xpected-error@+1 {{__float128 is not supported on this target}}
48
- __float128 overlookedBadFloat = 40 ;
66
+ // ======= Zero Length Arrays Not Allowed in Kernel ==========
67
+ // expected-error@+1 {{zero-length arrays are not permitted in C++}}
68
+ int MalArray[0 ];
69
+ // expected-error@+1 {{zero-length arrays are not permitted in C++}}
70
+ intDef MalArrayDef[0 ];
71
+ // ---- false positive tests. These should not generate any errors.
72
+ foo<int [0 ]>();
73
+ std::size_t arrSz = sizeof (int [0 ]);
74
+
75
+ // ======= Float128 Not Allowed in Kernel ==========
76
+ // expected-error@+1 {{'__float128' is not supported on this target}}
77
+ __float128 malFloat = 40 ;
78
+ // expected-error@+1 {{'__float128' is not supported on this target}}
79
+ trickyFloatType malFloatTrick = 41 ;
80
+ // expected-error@+1 {{'__float128' is not supported on this target}}
81
+ floatDef malFloatDef = 44 ;
82
+ // expected-error@+1 {{'__float128' is not supported on this target}}
83
+ auto whatFloat = malFloat;
84
+ // expected-error@+1 {{'__float128' is not supported on this target}}
85
+ auto malAutoTemp5 = bar<__float128>();
86
+ // expected-error@+1 {{'__float128' is not supported on this target}}
87
+ auto malAutoTemp6 = bar<trickyFloatType>();
88
+ // expected-error@+1 {{'__float128' is not supported on this target}}
89
+ decltype (malFloat) malDeclFloat = 42 ;
90
+ // ---- false positive tests
91
+ std::size_t someSz = sizeof (__float128);
92
+ foo<__float128>();
93
+
94
+ // ======= __int128 Not Allowed in Kernel ==========
95
+ // expected-error@+1 {{'__int128' is not supported on this target}}
96
+ __int128 malIntent = 2 ;
97
+ // expected-error@+1 {{'__int128' is not supported on this target}}
98
+ tricky128Type mal128Trick = 2 ;
99
+ // expected-error@+1 {{'__int128' is not supported on this target}}
100
+ int128Def malIntDef = 9 ;
101
+ // expected-error@+1 {{'__int128' is not supported on this target}}
102
+ auto whatInt128 = malIntent;
103
+ // expected-error@+1 {{'__int128' is not supported on this target}}
104
+ auto malAutoTemp = bar<__int128>();
105
+ // expected-error@+1 {{'__int128' is not supported on this target}}
106
+ auto malAutoTemp2 = bar<tricky128Type>();
107
+ // expected-error@+1 {{'__int128' is not supported on this target}}
108
+ decltype (malIntent) malDeclInt = 2 ;
109
+
110
+ // expected-error@+1 {{'__int128' is not supported on this target}}
111
+ __int128_t malInt128 = 2 ;
112
+ // expected-error@+1 {{'unsigned __int128' is not supported on this target}}
113
+ __uint128_t malUInt128 = 3 ;
114
+ // expected-error@+1 {{'unsigned __int128' is not supported on this target}}
115
+ megeType malTypeDefTrick = 4 ;
116
+ // expected-error@+1 {{'__int128' is not supported on this target}}
117
+ int128tDef malInt2Def = 6 ;
118
+ // expected-error@+1 {{'unsigned __int128' is not supported on this target}}
119
+ auto whatUInt = malUInt128;
120
+ // expected-error@+1 {{'__int128' is not supported on this target}}
121
+ auto malAutoTemp3 = bar<__int128_t >();
122
+ // expected-error@+1 {{'unsigned __int128' is not supported on this target}}
123
+ auto malAutoTemp4 = bar<megeType>();
124
+ // expected-error@+1 {{'__int128' is not supported on this target}}
125
+ decltype (malInt128) malDeclInt128 = 5 ;
126
+
127
+ // ---- false positive tests These should not generate any errors.
128
+ std::size_t i128Sz = sizeof (__int128);
129
+ foo<__int128>();
130
+ std::size_t u128Sz = sizeof (__uint128_t );
131
+ foo<__int128_t >();
132
+
133
+ // ========= variadic
134
+ // expected-error@+1 {{SYCL kernel cannot call a variadic function}}
135
+ variadic (5 );
49
136
});
50
137
}
51
138
@@ -56,7 +143,7 @@ int main(int argc, char **argv) {
56
143
// expected-error@+1 {{zero-length arrays are not permitted in C++}}
57
144
int BadArray[0 ];
58
145
59
- // expected-error@+1 {{__float128 is not supported on this target}}
146
+ // expected-error@+1 {{' __float128' is not supported on this target}}
60
147
__float128 badFloat = 40 ; // this SHOULD trigger a diagnostic
61
148
62
149
// expected-error@+1 {{SYCL kernel cannot call a variadic function}}
0 commit comments