Skip to content

Commit 8ad82b4

Browse files
committed
[clang][Interp] Fix re-visiting OpenCL variables of in constant AS
We need to use isConstant() here, isConstQualified() is not enough.
1 parent 6fc63ab commit 8ad82b4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3964,7 +3964,7 @@ bool ByteCodeExprGen<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
39643964
if (const auto *VD = dyn_cast<VarDecl>(D)) {
39653965
// Visit local const variables like normal.
39663966
if ((VD->isLocalVarDecl() || VD->isStaticDataMember()) &&
3967-
VD->getType().isConstQualified()) {
3967+
VD->getType().isConstant(Ctx.getASTContext())) {
39683968
if (!this->visitVarDecl(VD))
39693969
return false;
39703970
// Retry.
@@ -3973,8 +3973,8 @@ bool ByteCodeExprGen<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
39733973
}
39743974
} else {
39753975
if (const auto *VD = dyn_cast<VarDecl>(D);
3976-
VD && VD->getAnyInitializer() && VD->getType().isConstQualified() &&
3977-
!VD->isWeak()) {
3976+
VD && VD->getAnyInitializer() &&
3977+
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak()) {
39783978
if (!this->visitVarDecl(VD))
39793979
return false;
39803980
// Retry.

clang/test/AST/Interp/opencl.cl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,10 @@ void negativeShift32(int a,int b) {
3636

3737
int2 A = {1,2};
3838
int4 B = {(int2)(1,2), (int2)(3,4)};
39+
40+
41+
constant int sz0 = 5;
42+
kernel void testvla()
43+
{
44+
int vla0[sz0];
45+
}

0 commit comments

Comments
 (0)