[PATCH] D20090: [OPENCL] Fix wrongly vla error for OpenCL array.
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 6 20:20:15 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271971: [OPENCL] Fix wrongly vla error for OpenCL array. (authored by pxl).
Changed prior to commit:
http://reviews.llvm.org/D20090?vs=58932&id=59823#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20090
Files:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenOpenCL/vla.cl
Index: cfe/trunk/lib/AST/ExprConstant.cpp
===================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -2745,7 +2745,10 @@
} else if (VD->isConstexpr()) {
// OK, we can read this variable.
} else if (BaseType->isIntegralOrEnumerationType()) {
- if (!BaseType.isConstQualified()) {
+ // In OpenCL if a variable is in constant address space it is a const value.
+ if (!(BaseType.isConstQualified() ||
+ (Info.getLangOpts().OpenCL &&
+ BaseType.getAddressSpace() == LangAS::opencl_constant))) {
if (Info.getLangOpts().CPlusPlus) {
Info.Diag(E, diag::note_constexpr_ltor_non_const_int, 1) << VD;
Info.Note(VD->getLocation(), diag::note_declared_at);
Index: cfe/trunk/lib/Sema/SemaType.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -2063,7 +2063,8 @@
} Diagnoser;
return S.VerifyIntegerConstantExpression(ArraySize, &SizeVal, Diagnoser,
- S.LangOpts.GNUMode).isInvalid();
+ S.LangOpts.GNUMode ||
+ S.LangOpts.OpenCL).isInvalid();
}
/// \brief Build an array type.
Index: cfe/trunk/test/CodeGenOpenCL/vla.cl
===================================================================
--- cfe/trunk/test/CodeGenOpenCL/vla.cl
+++ cfe/trunk/test/CodeGenOpenCL/vla.cl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+constant int sz0 = 5;
+// CHECK: @sz0 = constant i32 5, align 4
+const global int sz1 = 16;
+// CHECK: @sz1 = constant i32 16, align 4
+const constant int sz2 = 8;
+// CHECK: @sz2 = constant i32 8, align 4
+// CHECK: @testvla.vla2 = internal global [8 x i16] undef, align 16
+
+kernel void testvla()
+{
+ int vla0[sz0];
+// CHECK: %vla0 = alloca [5 x i32], align 16
+ char vla1[sz1];
+// CHECK: %vla1 = alloca [16 x i8], align 16
+ local short vla2[sz2];
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20090.59823.patch
Type: text/x-patch
Size: 2138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160607/7a74dd66/attachment.bin>
More information about the cfe-commits
mailing list