File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
177
177
bool VisitMemberExpr (MemberExpr *E) {
178
178
if (VarDecl *VD = dyn_cast<VarDecl>(E->getMemberDecl ())) {
179
179
bool IsConst = VD->getType ().getNonReferenceType ().isConstQualified ();
180
- if (VD->isStaticDataMember () && !IsConst )
180
+ if (!IsConst && VD->isStaticDataMember ())
181
181
SemaRef.Diag (E->getExprLoc (), diag::err_sycl_restrict)
182
182
<< KernelNonConstStaticDataVariable;
183
183
}
@@ -188,7 +188,10 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
188
188
CheckSYCLType (E->getType (), E->getSourceRange ());
189
189
if (VarDecl *VD = dyn_cast<VarDecl>(E->getDecl ())) {
190
190
bool IsConst = VD->getType ().getNonReferenceType ().isConstQualified ();
191
- if (!IsConst && VD->hasGlobalStorage () && !VD->isStaticLocal () &&
191
+ if (!IsConst && VD->isStaticDataMember ())
192
+ SemaRef.Diag (E->getExprLoc (), diag::err_sycl_restrict)
193
+ << KernelNonConstStaticDataVariable;
194
+ else if (!IsConst && VD->hasGlobalStorage () && !VD->isStaticLocal () &&
192
195
!VD->isStaticDataMember () && !isa<ParmVarDecl>(VD))
193
196
SemaRef.Diag (E->getLocation (), diag::err_sycl_restrict)
194
197
<< KernelGlobalVariable;
Original file line number Diff line number Diff line change @@ -90,6 +90,12 @@ typedef struct A {
90
90
static int stat_member;
91
91
const static int const_stat_member;
92
92
constexpr static int constexpr_stat_member=0 ;
93
+
94
+ int fm (void )
95
+ {
96
+ // expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
97
+ return stat_member;
98
+ }
93
99
} a_type;
94
100
95
101
@@ -147,12 +153,15 @@ extern "C++" {
147
153
}
148
154
}
149
155
150
- int use2 ( a_type ab ) {
156
+ int use2 ( a_type ab, a_type *abp ) {
151
157
152
158
if (ab.constexpr_stat_member ) return 2 ;
153
159
if (ab.const_stat_member ) return 1 ;
154
160
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
155
161
if (ab.stat_member ) return 0 ;
162
+ // expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
163
+ if (abp->stat_member ) return 0 ;
164
+ if (ab.fm ()) return 0 ;
156
165
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
157
166
return another_global ;
158
167
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
@@ -169,7 +178,8 @@ template <typename name, typename Func>
169
178
__attribute__ ((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
170
179
kernelFunc ();
171
180
a_type ab;
172
- use2 (ab);
181
+ a_type *p;
182
+ use2 (ab, p);
173
183
}
174
184
175
185
int main () {
You can’t perform that action at this time.
0 commit comments