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
11
10
// we're testing a restricted mode, thus just provide a stub implementation for
12
11
// function with address-space-unspecified pointers.
13
- void * operator new (std::size_t ) {
12
+ void * operator new (std::size_t ) {
14
13
return reinterpret_cast <void *>(1 );
15
14
}
16
15
17
16
namespace Check_User_Operators {
18
- class Fraction
19
- {
20
- // expected-error@+2 {{SYCL kernel cannot call a recursive function }}
21
- // expected-note@+1 {{function implemented using recursion declared here} }
22
- int gcd ( int a, int b) { return b == 0 ? a : gcd (b, a % b); }
23
- int n, d;
17
+ class Fraction {
18
+ // expected-error@+2 {{SYCL kernel cannot call a recursive function}}
19
+ // expected-note@+1 {{function implemented using recursion declared here }}
20
+ int gcd ( int a, int b) { return b == 0 ? a : gcd (b, a % b); }
21
+ int n, d;
22
+
24
23
public:
25
- Fraction (int n, int d = 1 ) : n(n/ gcd(n, d)), d(d/ gcd(n, d)) { }
26
- int num () const { return n; }
27
- int den () const { return d; }
24
+ Fraction (int n, int d = 1 ) : n(n / gcd(n, d)), d(d / gcd(n, d)) {}
25
+ int num () const { return n; }
26
+ int den () const { return d; }
28
27
};
29
- bool operator ==(const Fraction& lhs, const Fraction& rhs)
30
- {
31
- new int ; // expected-error {{SYCL kernel cannot allocate storage}}
32
- return lhs. num () == rhs. num () && lhs. den () == rhs. den ();
33
- }}
28
+ bool operator ==(const Fraction & lhs, const Fraction & rhs) {
29
+ new int ; // expected-error {{SYCL kernel cannot allocate storage}}
30
+ return lhs. num () == rhs. num () && lhs. den () == rhs. den ();
31
+ }
32
+ } // namespace Check_User_Operators
34
33
35
34
namespace Check_VLA_Restriction {
36
35
void no_restriction (int p) {
37
- int index[p+ 2 ];
36
+ int index[p + 2 ];
38
37
}
39
38
void restriction (int p) {
40
39
// expected-error@+1 {{variable length arrays are not supported for the current target}}
41
- int index[p+2 ];
42
- }
40
+ int index[p + 2 ];
43
41
}
42
+ } // namespace Check_VLA_Restriction
44
43
45
- void * operator new (std::size_t size, void * ptr) throw () { return ptr; };
44
+ void * operator new (std::size_t size, void * ptr) throw () { return ptr; };
46
45
namespace Check_RTTI_Restriction {
47
46
struct A {
48
47
virtual ~A (){};
@@ -57,35 +56,38 @@ struct OverloadedNewDelete {
57
56
void *operator new (std::size_t size) throw () {
58
57
// expected-error@+1 {{SYCL kernel cannot allocate storage}}
59
58
float *pt = new float ;
60
- return 0 ;}
59
+ return 0 ;
60
+ }
61
61
// This overload does not allocate: no diagnostic.
62
- void *operator new [](std::size_t size) throw () {return 0 ;}
62
+ void *operator new [](std::size_t size) throw () { return 0 ; }
63
63
void operator delete (void *){};
64
64
void operator delete[] (void *){};
65
65
};
66
66
67
67
bool isa_B (A *a) {
68
68
Check_User_Operators::Fraction f1 (3 , 8 ), f2 (1 , 2 ), f3 (10 , 2 );
69
- if (f1 == f2) return false ;
69
+ if (f1 == f2)
70
+ return false ;
70
71
71
72
Check_VLA_Restriction::restriction (7 );
72
73
// expected-error@+1 {{SYCL kernel cannot allocate storage}}
73
74
int *ip = new int ;
74
- int i; int *p3 = new (&i) int ; // no error on placement new
75
+ int i;
76
+ int *p3 = new (&i) int ; // no error on placement new
75
77
// expected-note@+1 {{called by 'isa_B'}}
76
- OverloadedNewDelete *x = new ( struct OverloadedNewDelete );
77
- auto y = new struct OverloadedNewDelete [5 ];
78
+ OverloadedNewDelete *x = new ( struct OverloadedNewDelete );
79
+ auto y = new struct OverloadedNewDelete [5 ];
78
80
// expected-error@+1 {{SYCL kernel cannot use rtti}}
79
81
(void )typeid (int );
80
82
// expected-error@+1 {{SYCL kernel cannot use rtti}}
81
83
return dynamic_cast <B *>(a) != 0 ;
82
84
}
83
85
84
- template <typename N, typename L>
86
+ template <typename N, typename L>
85
87
__attribute__ ((sycl_kernel)) void kernel1 (L l) {
86
88
l ();
87
89
}
88
- }
90
+ } // namespace Check_RTTI_Restriction
89
91
90
92
typedef struct Base {
91
93
virtual void f () const {}
@@ -94,22 +96,19 @@ typedef struct Base {
94
96
typedef struct A {
95
97
static int stat_member;
96
98
const static int const_stat_member;
97
- constexpr static int constexpr_stat_member= 0 ;
99
+ constexpr static int constexpr_stat_member = 0 ;
98
100
99
- int fm (void )
100
- {
101
+ int fm (void ) {
101
102
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
102
103
return stat_member;
103
104
}
104
105
} a_type;
105
106
106
-
107
107
b_type b;
108
108
109
- using myFuncDef = int (int ,int );
109
+ using myFuncDef = int (int , int );
110
110
111
- void eh_ok (void )
112
- {
111
+ void eh_ok (void ) {
113
112
__float128 A;
114
113
try {
115
114
;
@@ -119,8 +118,7 @@ void eh_ok(void)
119
118
throw 20 ;
120
119
}
121
120
122
- void eh_not_ok (void )
123
- {
121
+ void eh_not_ok (void ) {
124
122
// expected-error@+1 {{SYCL kernel cannot use exceptions}}
125
123
try {
126
124
;
@@ -153,44 +151,50 @@ void usage(myFuncDef functionPtr) {
153
151
}
154
152
155
153
namespace ns {
156
- int glob;
154
+ int glob;
157
155
}
158
156
extern " C++" {
159
- int another_global = 5 ;
160
- namespace AnotherNS {
161
- int moar_globals = 5 ;
162
- }
157
+ int another_global = 5 ;
158
+ namespace AnotherNS {
159
+ int moar_globals = 5 ;
160
+ }
163
161
}
164
162
165
163
int addInt (int n, int m) {
166
- return n+ m;
164
+ return n + m;
167
165
}
168
166
169
- int use2 ( a_type ab, a_type *abp ) {
167
+ int use2 ( a_type ab, a_type *abp) {
170
168
171
- if (ab.constexpr_stat_member ) return 2 ;
172
- if (ab.const_stat_member ) return 1 ;
169
+ if (ab.constexpr_stat_member )
170
+ return 2 ;
171
+ if (ab.const_stat_member )
172
+ return 1 ;
173
173
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
174
- if (ab.stat_member ) return 0 ;
174
+ if (ab.stat_member )
175
+ return 0 ;
175
176
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
176
- if (abp->stat_member ) return 0 ;
177
- if (ab.fm ()) return 0 ;
177
+ if (abp->stat_member )
178
+ return 0 ;
179
+ if (ab.fm ())
180
+ return 0 ;
178
181
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
179
- return another_global ;
182
+ return another_global;
180
183
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
181
184
return ns::glob +
182
- // expected-error@+1 {{SYCL kernel cannot use a global variable}}
183
- AnotherNS::moar_globals;
185
+ // expected-error@+1 {{SYCL kernel cannot use a global variable}}
186
+ AnotherNS::moar_globals;
184
187
// expected-note@+1 {{called by 'use2'}}
185
188
eh_not_ok ();
186
- Check_RTTI_Restriction:: A *a;
189
+ Check_RTTI_Restriction::A *a;
187
190
// expected-note@+1 2{{called by 'use2'}}
188
- Check_RTTI_Restriction:: isa_B (a);
191
+ Check_RTTI_Restriction::isa_B (a);
189
192
// expected-note@+1 {{called by 'use2'}}
190
193
usage (&addInt);
191
194
Check_User_Operators::Fraction f1 (3 , 8 ), f2 (1 , 2 ), f3 (10 , 2 );
192
195
// expected-note@+1 {{called by 'use2'}}
193
- if (f1 == f2) return false ;
196
+ if (f1 == f2)
197
+ return false ;
194
198
}
195
199
196
200
template <typename name, typename Func>
@@ -204,7 +208,6 @@ __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
204
208
205
209
int main () {
206
210
a_type ab;
207
- kernel_single_task<class fake_kernel >([]() { usage ( &addInt ); });
211
+ kernel_single_task<class fake_kernel >([]() { usage (&addInt); });
208
212
return 0 ;
209
213
}
210
-
0 commit comments