[cfe-commits] r120899 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/CodeGenObjC/property.m

John McCall rjmccall at apple.com
Sat Dec 4 01:03:57 PST 2010


Author: rjmccall
Date: Sat Dec  4 03:03:57 2010
New Revision: 120899

URL: http://llvm.org/viewvc/llvm-project?rev=120899&view=rev
Log:
Don't crash when initializing a subaggregate in C from a property r-value.


Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/CodeGenObjC/property.m

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=120899&r1=120898&r2=120899&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sat Dec  4 03:03:57 2010
@@ -698,6 +698,7 @@
       //   that of the expression.
       if ((ElemType->isRecordType() || ElemType->isVectorType()) &&
           SemaRef.Context.hasSameUnqualifiedType(expr->getType(), ElemType)) {
+        SemaRef.DefaultFunctionArrayLvalueConversion(expr);
         UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
         ++Index;
         return;

Modified: cfe/trunk/test/CodeGenObjC/property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/property.m?rev=120899&r1=120898&r2=120899&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/property.m (original)
+++ cfe/trunk/test/CodeGenObjC/property.m Sat Dec  4 03:03:57 2010
@@ -77,3 +77,15 @@
   // 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; };
+ at interface test3_object
+ at property struct test3_struct s;
+ at end
+void test3(test3_object *p) {
+  struct test3_struct array[1] = { p.s };
+  struct test3_nested agg = { p.s };
+}





More information about the cfe-commits mailing list