r190844 - Fix const-eval of vector init-lists of a vector.

Eli Friedman eli.friedman at gmail.com
Mon Sep 16 21:07:02 PDT 2013


Author: efriedma
Date: Mon Sep 16 23:07:02 2013
New Revision: 190844

URL: http://llvm.org/viewvc/llvm-project?rev=190844&view=rev
Log:
Fix const-eval of vector init-lists of a vector.

Like any other type, an init list for a vector can have the same type as
the vector itself; handle that case.

<rdar://problem/14990460>

Added:
    cfe/trunk/test/CodeGenCXX/static-init-4.cpp
Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=190844&r1=190843&r2=190844&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Sep 16 23:07:02 2013
@@ -5262,7 +5262,7 @@ VectorExprEvaluator::VisitInitListExpr(c
   while (CountElts < NumElements) {
     // Handle nested vector initialization.
     if (CountInits < NumInits 
-        && E->getInit(CountInits)->getType()->isExtVectorType()) {
+        && E->getInit(CountInits)->getType()->isVectorType()) {
       APValue v;
       if (!EvaluateVector(E->getInit(CountInits), v, Info))
         return Error(E);

Added: cfe/trunk/test/CodeGenCXX/static-init-4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-init-4.cpp?rev=190844&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/static-init-4.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/static-init-4.cpp Mon Sep 16 23:07:02 2013
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
+
+typedef __attribute__((vector_size(4*4))) float float32x4_t;
+union QDSUnion { float32x4_t q; float s[4]; };
+constexpr float32x4_t a = {1,2,3,4};
+QDSUnion t = {{(a)}};
+// CHECK: @t = global %union.QDSUnion { <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00> }





More information about the cfe-commits mailing list