diff options
-rw-r--r-- | lib/Sema/SemaInit.cpp | 2 | ||||
-rw-r--r-- | test/Sema/init-vector.c | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 4e0eb1d431..45085962d4 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -674,7 +674,7 @@ void InitListChecker::CheckSubElementType(InitListExpr *IList, // 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; diff --git a/test/Sema/init-vector.c b/test/Sema/init-vector.c new file mode 100644 index 0000000000..691ea97268 --- /dev/null +++ b/test/Sema/init-vector.c @@ -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; +} |