[cfe-commits] r73292 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/Sema/init-vector.c

Eli Friedman eli.friedman at gmail.com
Sat Jun 13 03:38:47 PDT 2009


Author: efriedma
Date: Sat Jun 13 05:38:46 2009
New Revision: 73292

URL: http://llvm.org/viewvc/llvm-project?rev=73292&view=rev
Log:
Allow initializing a vector with a vector in addition to allowing a list 
of the elements.  Issue reported on cfe-dev by Mattias Holm.


Added:
    cfe/trunk/test/Sema/init-vector.c
Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=73292&r1=73291&r2=73292&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sat Jun 13 05:38:46 2009
@@ -674,7 +674,7 @@
       //   compatible structure or union type. In the latter case, the
       //   initial value of the object, including unnamed members, is
       //   that of the expression.
-      if (ElemType->isRecordType() &&
+      if ((ElemType->isRecordType() || ElemType->isVectorType()) &&
           SemaRef.Context.hasSameUnqualifiedType(expr->getType(), ElemType)) {
         UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
         ++Index;

Added: cfe/trunk/test/Sema/init-vector.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/init-vector.c?rev=73292&view=auto

==============================================================================
--- cfe/trunk/test/Sema/init-vector.c (added)
+++ cfe/trunk/test/Sema/init-vector.c Sat Jun 13 05:38:46 2009
@@ -0,0 +1,17 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+typedef float __attribute__((vector_size (16))) v4f_t;
+
+typedef union {
+    struct {
+        float x, y, z, w;
+    }s;
+    v4f_t v;
+} vector_t;
+
+
+vector_t foo(v4f_t p)
+{
+  vector_t v = {.v = p};
+  return v;
+}





More information about the cfe-commits mailing list