2
2
// RUN: %clang_cc1 -fcxx-exceptions -triple spir64 -fsycl-is-device -fno-sycl-allow-func-ptr -Wno-return-type -verify -fsyntax-only -std=c++17 %s
3
3
// RUN: %clang_cc1 -fcxx-exceptions -triple spir64 -fsycl-is-device -DALLOW_FP=1 -fsycl-allow-func-ptr -Wno-return-type -verify -fsyntax-only -std=c++17 %s
4
4
5
-
6
5
namespace std {
7
- class type_info ;
8
- typedef __typeof__ (sizeof (int )) size_t;
9
- }
6
+ class type_info ;
7
+ typedef __typeof__ (sizeof (int )) size_t;
8
+ } // namespace std
10
9
namespace Check_User_Operators {
11
- class Fraction
12
- {
13
- // expected-error@+2 {{SYCL kernel cannot call a recursive function }}
14
- // expected-note@+1 {{function implemented using recursion declared here} }
15
- int gcd ( int a, int b) { return b == 0 ? a : gcd (b, a % b); }
16
- int n, d;
10
+ class Fraction {
11
+ // expected-error@+2 {{SYCL kernel cannot call a recursive function}}
12
+ // expected-note@+1 {{function implemented using recursion declared here }}
13
+ int gcd ( int a, int b) { return b == 0 ? a : gcd (b, a % b); }
14
+ int n, d;
15
+
17
16
public:
18
- Fraction (int n, int d = 1 ) : n(n/ gcd(n, d)), d(d/ gcd(n, d)) { }
19
- int num () const { return n; }
20
- int den () const { return d; }
17
+ Fraction (int n, int d = 1 ) : n(n / gcd(n, d)), d(d / gcd(n, d)) {}
18
+ int num () const { return n; }
19
+ int den () const { return d; }
21
20
};
22
- bool operator ==(const Fraction& lhs, const Fraction& rhs)
23
- {
24
- new int ; // expected-error {{SYCL kernel cannot allocate storage}}
25
- return lhs. num () == rhs. num () && lhs. den () == rhs. den ();
26
- }}
21
+ bool operator ==(const Fraction & lhs, const Fraction & rhs) {
22
+ new int ; // expected-error {{SYCL kernel cannot allocate storage}}
23
+ return lhs. num () == rhs. num () && lhs. den () == rhs. den ();
24
+ }
25
+ } // namespace Check_User_Operators
27
26
28
27
namespace Check_VLA_Restriction {
29
28
void no_restriction (int p) {
30
- int index [p+ 2 ];
29
+ int index [p + 2 ];
31
30
}
32
31
void restriction (int p) {
33
32
// expected-error@+1 {{variable length arrays are not supported for the current target}}
34
- int index [p+2 ];
35
- }
33
+ int index [p + 2 ];
36
34
}
35
+ } // namespace Check_VLA_Restriction
37
36
38
- void * operator new (std::size_t size, void * ptr) throw () { return ptr; };
37
+ void * operator new (std::size_t size, void * ptr) throw () { return ptr; };
39
38
namespace Check_RTTI_Restriction {
40
39
struct A {
41
40
virtual ~A (){};
@@ -50,35 +49,38 @@ struct OverloadedNewDelete {
50
49
void *operator new (std::size_t size) throw () {
51
50
// expected-error@+1 {{SYCL kernel cannot allocate storage}}
52
51
float *pt = new float ;
53
- return 0 ;}
52
+ return 0 ;
53
+ }
54
54
// This overload does not allocate: no diagnostic.
55
- void *operator new [](std::size_t size) throw () {return 0 ;}
55
+ void *operator new [](std::size_t size) throw () { return 0 ; }
56
56
void operator delete (void *){};
57
57
void operator delete[] (void *){};
58
58
};
59
59
60
60
bool isa_B (A *a) {
61
61
Check_User_Operators::Fraction f1 (3 , 8 ), f2 (1 , 2 ), f3 (10 , 2 );
62
- if (f1 == f2) return false ;
62
+ if (f1 == f2)
63
+ return false ;
63
64
64
65
Check_VLA_Restriction::restriction (7 );
65
66
// expected-error@+1 {{SYCL kernel cannot allocate storage}}
66
67
int *ip = new int ;
67
- int i; int *p3 = new (&i) int ; // no error on placement new
68
+ int i;
69
+ int *p3 = new (&i) int ; // no error on placement new
68
70
// expected-note@+1 {{called by 'isa_B'}}
69
- OverloadedNewDelete *x = new ( struct OverloadedNewDelete );
70
- auto y = new struct OverloadedNewDelete [5 ];
71
+ OverloadedNewDelete *x = new ( struct OverloadedNewDelete );
72
+ auto y = new struct OverloadedNewDelete [5 ];
71
73
// expected-error@+1 {{SYCL kernel cannot use rtti}}
72
74
(void )typeid (int );
73
75
// expected-error@+1 {{SYCL kernel cannot use rtti}}
74
76
return dynamic_cast <B *>(a) != 0 ;
75
77
}
76
78
77
- template <typename N, typename L>
79
+ template <typename N, typename L>
78
80
__attribute__ ((sycl_kernel)) void kernel1 (L l) {
79
81
l ();
80
82
}
81
- }
83
+ } // namespace Check_RTTI_Restriction
82
84
83
85
typedef struct Base {
84
86
virtual void f () const {}
@@ -87,22 +89,19 @@ typedef struct Base {
87
89
typedef struct A {
88
90
static int stat_member;
89
91
const static int const_stat_member;
90
- constexpr static int constexpr_stat_member= 0 ;
92
+ constexpr static int constexpr_stat_member = 0 ;
91
93
92
- int fm (void )
93
- {
94
+ int fm (void ) {
94
95
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
95
96
return stat_member;
96
97
}
97
98
} a_type;
98
99
99
-
100
100
b_type b;
101
101
102
- using myFuncDef = int (int ,int );
102
+ using myFuncDef = int (int , int );
103
103
104
- void eh_ok (void )
105
- {
104
+ void eh_ok (void ) {
106
105
__float128 A;
107
106
try {
108
107
;
@@ -112,8 +111,7 @@ void eh_ok(void)
112
111
throw 20 ;
113
112
}
114
113
115
- void eh_not_ok (void )
116
- {
114
+ void eh_not_ok (void ) {
117
115
// expected-error@+1 {{SYCL kernel cannot use exceptions}}
118
116
try {
119
117
;
@@ -146,45 +144,51 @@ void usage(myFuncDef functionPtr) {
146
144
}
147
145
148
146
namespace ns {
149
- int glob;
147
+ int glob;
150
148
}
151
149
extern " C++" {
152
- int another_global = 5 ;
153
- namespace AnotherNS {
154
- int moar_globals = 5 ;
155
- }
150
+ int another_global = 5 ;
151
+ namespace AnotherNS {
152
+ int moar_globals = 5 ;
153
+ }
156
154
}
157
155
158
156
int addInt (int n, int m) {
159
- return n+ m;
157
+ return n + m;
160
158
}
161
159
162
- int use2 ( a_type ab, a_type *abp ) {
160
+ int use2 ( a_type ab, a_type *abp) {
163
161
164
- if (ab.constexpr_stat_member ) return 2 ;
165
- if (ab.const_stat_member ) return 1 ;
162
+ if (ab.constexpr_stat_member )
163
+ return 2 ;
164
+ if (ab.const_stat_member )
165
+ return 1 ;
166
166
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
167
- if (ab.stat_member ) return 0 ;
167
+ if (ab.stat_member )
168
+ return 0 ;
168
169
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
169
- if (abp->stat_member ) return 0 ;
170
+ if (abp->stat_member )
171
+ return 0 ;
170
172
// expected-note@+1 {{called by 'use2'}}
171
- if (ab.fm ()) return 0 ;
173
+ if (ab.fm ())
174
+ return 0 ;
172
175
// expected-error@+1 {{SYCL kernel cannot use a non-const global variable}}
173
- return another_global ;
176
+ return another_global;
174
177
// expected-error@+1 {{SYCL kernel cannot use a non-const global variable}}
175
178
return ns::glob +
176
- // expected-error@+1 {{SYCL kernel cannot use a non-const global variable}}
177
- AnotherNS::moar_globals;
179
+ // expected-error@+1 {{SYCL kernel cannot use a non-const global variable}}
180
+ AnotherNS::moar_globals;
178
181
// expected-note@+1 {{called by 'use2'}}
179
182
eh_not_ok ();
180
- Check_RTTI_Restriction:: A *a;
183
+ Check_RTTI_Restriction::A *a;
181
184
// expected-note@+1 2{{called by 'use2'}}
182
- Check_RTTI_Restriction:: isa_B (a);
185
+ Check_RTTI_Restriction::isa_B (a);
183
186
// expected-note@+1 {{called by 'use2'}}
184
187
usage (&addInt);
185
188
Check_User_Operators::Fraction f1 (3 , 8 ), f2 (1 , 2 ), f3 (10 , 2 );
186
189
// expected-note@+1 {{called by 'use2'}}
187
- if (f1 == f2) return false ;
190
+ if (f1 == f2)
191
+ return false ;
188
192
}
189
193
190
194
template <typename name, typename Func>
@@ -198,7 +202,6 @@ __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
198
202
199
203
int main () {
200
204
a_type ab;
201
- kernel_single_task<class fake_kernel >([]() { usage ( &addInt ); });
205
+ kernel_single_task<class fake_kernel >([]() { usage (&addInt); });
202
206
return 0 ;
203
207
}
204
-
0 commit comments