diff options
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 9 | ||||
-rw-r--r-- | test/CodeGenObjC/arc-blocks.m | 4 |
4 files changed, 14 insertions, 9 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 80d754a98a..6ea21ec47a 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -905,10 +905,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) { } } - QualType elementType = E->getType().getCanonicalType(); - elementType = CGF.getContext().getQualifiedType( - cast<ArrayType>(elementType)->getElementType(), - elementType.getQualifiers() + Dest.getQualifiers()); + QualType elementType = + CGF.getContext().getAsArrayType(E->getType())->getElementType(); llvm::PointerType *APType = cast<llvm::PointerType>(DestPtr->getType()); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 94d8f62ba6..05136b882b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -6226,10 +6226,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, // completed by the initializer. For example: // int ary[] = { 1, 3, 5 }; // "ary" transitions from an IncompleteArrayType to a ConstantArrayType. - if (!VDecl->isInvalidDecl() && (DclT != SavT)) { + if (!VDecl->isInvalidDecl() && (DclT != SavT)) VDecl->setType(DclT); - Init->setType(DclT.getNonReferenceType()); - } // Check any implicit conversions within the expression. CheckImplicitConversions(Init, VDecl->getLocation()); diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 1a62d246e4..31e4ecb939 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -604,7 +604,9 @@ void InitListChecker::CheckExplicitInitList(const InitializedEntity &Entity, CheckListElementTypes(Entity, IList, T, /*SubobjectIsDesignatorContext=*/true, Index, StructuredList, StructuredIndex, TopLevelObject); if (!VerifyOnly) { - QualType ExprTy = T.getNonLValueExprType(SemaRef.Context); + QualType ExprTy = T; + if (!ExprTy->isArrayType()) + ExprTy = ExprTy.getNonLValueExprType(SemaRef.Context); IList->setType(ExprTy); StructuredList->setType(ExprTy); } @@ -2077,7 +2079,10 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index, InitRange.getBegin(), 0, 0, InitRange.getEnd()); - Result->setType(CurrentObjectType.getNonLValueExprType(SemaRef.Context)); + QualType ResultType = CurrentObjectType; + if (!ResultType->isArrayType()) + ResultType = ResultType.getNonLValueExprType(SemaRef.Context); + Result->setType(ResultType); // Pre-allocate storage for the structured initializer list. unsigned NumElements = 0; diff --git a/test/CodeGenObjC/arc-blocks.m b/test/CodeGenObjC/arc-blocks.m index f11a31e468..bde5ec3747 100644 --- a/test/CodeGenObjC/arc-blocks.m +++ b/test/CodeGenObjC/arc-blocks.m @@ -510,3 +510,7 @@ void test13(id x) { // CHECK-NEXT: ret void } +// <rdar://problem/10907510> +void test14() { + void (^const x[1])(void) = { ^{} }; +} |