]> granicus.if.org Git - clang/commitdiff
Fix const-eval of vector init-lists of a vector.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 17 Sep 2013 04:07:02 +0000 (04:07 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 17 Sep 2013 04:07:02 +0000 (04:07 +0000)
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>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190844 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/CodeGenCXX/static-init-4.cpp [new file with mode: 0644]

index 0a2cc7b3d6d53a73a8a126caf5c2ba562b595e40..8ca33cbd20c5756ed089f1cf74f49ca92ef04a55 100644 (file)
@@ -5262,7 +5262,7 @@ VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   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);
diff --git a/test/CodeGenCXX/static-init-4.cpp b/test/CodeGenCXX/static-init-4.cpp
new file mode 100644 (file)
index 0000000..a4bb987
--- /dev/null
@@ -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> }