From 2ed087edfa4081c89a6f65da3cf2ea9d4e3ae48a Mon Sep 17 00:00:00 2001
From: Xiuli Pan <xiulipan@outlook.com>
Date: Tue, 7 Jun 2016 03:41:07 +0000
Subject: [PATCH] Revert "[OPENCL] Fix wrongly vla error for OpenCL array."

Test case break on system-z.

This reverts commit 9a7212e1e87f1396952d74f8c62314a775ccbb1c.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271975 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/AST/ExprConstant.cpp  |  5 +----
 lib/Sema/SemaType.cpp     |  3 +--
 test/CodeGenOpenCL/vla.cl | 18 ------------------
 3 files changed, 2 insertions(+), 24 deletions(-)
 delete mode 100644 test/CodeGenOpenCL/vla.cl

diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index e14330cf60e..8c24b0333e1 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -2745,10 +2745,7 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
       } else if (VD->isConstexpr()) {
         // OK, we can read this variable.
       } else if (BaseType->isIntegralOrEnumerationType()) {
-        // 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 (!BaseType.isConstQualified()) {
           if (Info.getLangOpts().CPlusPlus) {
             Info.Diag(E, diag::note_constexpr_ltor_non_const_int, 1) << VD;
             Info.Note(VD->getLocation(), diag::note_declared_at);
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index ddcdef84310..9786f7fb4f8 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -2063,8 +2063,7 @@ static bool isArraySizeVLA(Sema &S, Expr *ArraySize, llvm::APSInt &SizeVal) {
   } Diagnoser;
 
   return S.VerifyIntegerConstantExpression(ArraySize, &SizeVal, Diagnoser,
-                                           S.LangOpts.GNUMode ||
-                                           S.LangOpts.OpenCL).isInvalid();
+                                           S.LangOpts.GNUMode).isInvalid();
 }
 
 /// \brief Build an array type.
diff --git a/test/CodeGenOpenCL/vla.cl b/test/CodeGenOpenCL/vla.cl
deleted file mode 100644
index 56533aba5dd..00000000000
--- a/test/CodeGenOpenCL/vla.cl
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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];
-}
-- 
GitLab