Skip to content

Commit c64ae49

Browse files
committed
[SYCL] non-const static variables defined outside kernel must be forbidden in it. (fix #2)
Signed-off-by: Aleksander Fadeev <aleksander.fadeev@intel.com>
1 parent cd7b8c5 commit c64ae49

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

clang/test/SemaSYCL/sycl-restrict.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ typedef struct A {
9191

9292
int fm(void)
9393
{
94+
// expected-error@+2 {{SYCL kernel cannot use a non-const static data variable}}
9495
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
9596
return stat_member;
9697
}
@@ -134,7 +135,7 @@ void usage(myFuncDef functionPtr) {
134135
// expected-error@+2 {{SYCL kernel cannot call through a function pointer}}
135136
#endif
136137
if ((*functionPtr)(1, 2))
137-
// expected-error@+2 {{SYCL kernel cannot use a global variable}}
138+
// expected-error@+2 {{SYCL kernel cannot use a non-const global variable}}
138139
// expected-error@+1 {{SYCL kernel cannot call a virtual function}}
139140
b.f();
140141
Check_RTTI_Restriction::kernel1<class kernel_name>([]() {
@@ -163,16 +164,18 @@ int use2 ( a_type ab, a_type *abp ) {
163164

164165
if (ab.constexpr_stat_member) return 2;
165166
if (ab.const_stat_member) return 1;
167+
// expected-error@+2 {{SYCL kernel cannot use a non-const static data variable}}
166168
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
167169
if (ab.stat_member) return 0;
170+
// expected-error@+2 {{SYCL kernel cannot use a non-const static data variable}}
168171
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
169172
if (abp->stat_member) return 0;
170173
if (ab.fm()) return 0;
171-
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
174+
// expected-error@+1 {{SYCL kernel cannot use a non-const global variable}}
172175
return another_global ;
173-
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
176+
// expected-error@+1 {{SYCL kernel cannot use a non-const global variable}}
174177
return ns::glob +
175-
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
178+
// expected-error@+1 {{SYCL kernel cannot use a non-const global variable}}
176179
AnotherNS::moar_globals;
177180
// expected-note@+1 {{called by 'use2'}}
178181
eh_not_ok();

clang/test/SemaSYCL/tls_error.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ extern __thread void (*__once_call)(); // expected-no-error
55

66
void usage() {
77
// expected-error@+2{{thread-local storage is not supported for the current target}}
8-
// expected-error@+1{{SYCL kernel cannot use a global variable}}
8+
// expected-error@+1{{SYCL kernel cannot use a non-const global variable}}
99
__once_callable = 0;
1010
// expected-error@+3{{thread-local storage is not supported for the current target}}
11-
// expected-error@+2{{SYCL kernel cannot use a global variable}}
11+
// expected-error@+2{{SYCL kernel cannot use a non-const global variable}}
1212
// expected-error@+1{{SYCL kernel cannot call through a function pointer}}
1313
__once_call();
1414
}

0 commit comments

Comments
 (0)