summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorXiuli Pan <xiulipan@outlook.com>2016-06-07 03:13:39 +0000
committerXiuli Pan <xiulipan@outlook.com>2016-06-07 03:13:39 +0000
commitbdfbaaaefea3a15d3658ed4354804324811cd789 (patch)
tree0d2845fbfb3bb1b8992fecb14bb9290998c9bbc1 /clang/lib/AST
parentc7afda5a0942a0fe3bd814d1f6a308e1dd817053 (diff)
downloadbcm5719-llvm-bdfbaaaefea3a15d3658ed4354804324811cd789.tar.gz
bcm5719-llvm-bdfbaaaefea3a15d3658ed4354804324811cd789.zip
[OPENCL] Fix wrongly vla error for OpenCL array.
Summary: OpenCL should support array with const value size length, those const varibale in global and constant address space and variable in constant address space. Reviewers: Anastasia, yaxunl, bader Subscribers: bader, cfe-commits Differential Revision: http://reviews.llvm.org/D20090 llvm-svn: 271971
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ExprConstant.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 8c24b0333e1..e14330cf60e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2745,7 +2745,10 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
} 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);
OpenPOWER on IntegriCloud