]> granicus.if.org Git - clang/commitdiff
When initializing struct members, the important thing is that the "initializing"...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 1 Feb 2011 00:52:10 +0000 (00:52 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 1 Feb 2011 00:52:10 +0000 (00:52 +0000)
compatible, not having the same type.

Fix rdar://8183908 in which compatible vector types weren't initialized properly leading to a crash.

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

lib/Sema/SemaInit.cpp
test/CodeGen/struct-init.c

index 589e971ccb8a926953e5846fb42cc5f344489b72..3aeb5188270978a1010330a9a28682ce3ea2eddb 100644 (file)
@@ -697,7 +697,8 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity,
       //   initial value of the object, including unnamed members, is
       //   that of the expression.
       if ((ElemType->isRecordType() || ElemType->isVectorType()) &&
-          SemaRef.Context.hasSameUnqualifiedType(expr->getType(), ElemType)) {
+          SemaRef.CheckSingleAssignmentConstraints(ElemType, expr)
+              == Sema::Compatible) {
         SemaRef.DefaultFunctionArrayLvalueConversion(expr);
         UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
         ++Index;
index 926e5a7f5dd9b64bd51a5043e22dc43149463977..861c41e59cc3ba63a5c1d1fbf2125dc8fd97b0a9 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o -
+// RUN: %clang_cc1 %s -emit-llvm-only
 
 typedef struct _zend_ini_entry zend_ini_entry;
 struct _zend_ini_entry {
@@ -18,3 +18,14 @@ struct GLGENH {
 };
 
 struct GLGENH ABHFBF = {1};
+
+typedef __attribute__(( ext_vector_type(2) )) unsigned int uint2;
+typedef __attribute__(( __vector_size__(8) )) unsigned int __neon_uint32x2_t;
+
+// rdar://8183908
+typedef struct __simd64_uint32_t {
+  __neon_uint32x2_t val;
+} uint32x2_t;
+void foo() {
+    const uint32x2_t signBit = { (uint2) 0x80000000 };
+}