diff options
author | John McCall <rjmccall@apple.com> | 2010-12-04 09:03:57 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-12-04 09:03:57 +0000 |
commit | 211e699754cc23a2a634cfcd818e532f5c8c5d06 (patch) | |
tree | 735620c21438c8291de47d9f9a6f4c99dea41a68 | |
parent | 5a4ce8bf06ad66941e0c9466f2c68c68bcae33bf (diff) | |
download | bcm5719-llvm-211e699754cc23a2a634cfcd818e532f5c8c5d06.tar.gz bcm5719-llvm-211e699754cc23a2a634cfcd818e532f5c8c5d06.zip |
Don't crash when initializing a subaggregate in C from a property r-value.
llvm-svn: 120899
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 1 | ||||
-rw-r--r-- | clang/test/CodeGenObjC/property.m | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index d7048a129f1..7c4bd4a82e0 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -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; diff --git a/clang/test/CodeGenObjC/property.m b/clang/test/CodeGenObjC/property.m index 1e7ca232bed..fe8737e9176 100644 --- a/clang/test/CodeGenObjC/property.m +++ b/clang/test/CodeGenObjC/property.m @@ -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 }; +} |