]> granicus.if.org Git - clang/commitdiff
Don't crash when initializing a subaggregate in C from a property r-value.
authorJohn McCall <rjmccall@apple.com>
Sat, 4 Dec 2010 09:03:57 +0000 (09:03 +0000)
committerJohn McCall <rjmccall@apple.com>
Sat, 4 Dec 2010 09:03:57 +0000 (09:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120899 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp
test/CodeGenObjC/property.m

index d7048a129f1540baa5018fc897c16b1be82b5549..7c4bd4a82e03143b9d9d3d47634528a4604d3eed 100644 (file)
@@ -698,6 +698,7 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity,
       //   that of the expression.
       if ((ElemType->isRecordType() || ElemType->isVectorType()) &&
           SemaRef.Context.hasSameUnqualifiedType(expr->getType(), ElemType)) {
+        SemaRef.DefaultFunctionArrayLvalueConversion(expr);
         UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
         ++Index;
         return;
index 1e7ca232bedf5bc80a36725a7ad3ed84d28182e1..fe8737e917605706d7d2b4dfd456dc3fdd97996e 100644 (file)
@@ -77,3 +77,15 @@ void test2() {
   // CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32)*)(i8* [[BASETMP]], i8* [[SEL]], i32 [[ADD]])
   test2_helper().dyn *= 10;
 }
+
+// Test aggregate initialization from property reads.
+// Not crashing is good enough for the property-specific test.
+struct test3_struct { int x,y,z; };
+struct test3_nested { struct test3_struct t; };
+@interface test3_object
+@property struct test3_struct s;
+@end
+void test3(test3_object *p) {
+  struct test3_struct array[1] = { p.s };
+  struct test3_nested agg = { p.s };
+}