diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d45179e94c84..181d6d1c8f8a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3478,15 +3478,22 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty, InitializationKind Kind = InitializationKind::CreateCast(SourceRange(LParenLoc, RParenLoc), /*IsCStyleCast=*/true); - if (CheckInitializerTypes(literalExpr, literalType, Entity, Kind)) + InitializationSequence InitSeq(*this, Entity, Kind, &literalExpr, 1); + OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind, + MultiExprArg(*this, (void**)&literalExpr, 1), + &literalType); + if (Result.isInvalid()) return ExprError(); + InitExpr.release(); + literalExpr = static_cast(Result.get()); bool isFileScope = getCurFunctionOrMethodDecl() == 0; if (isFileScope) { // 6.5.2.5p3 if (CheckForConstantInitializer(literalExpr, literalType)) return ExprError(); } - InitExpr.release(); + + Result.release(); // FIXME: Store the TInfo to preserve type information better. return Owned(new (Context) CompoundLiteralExpr(LParenLoc, literalType, diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index c7a2769c4486..cc22e7458a43 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -3186,7 +3186,7 @@ InitializationSequence::Perform(Sema &S, } } - if (Kind.getKind() == InitializationKind::IK_Copy) + if (Kind.getKind() == InitializationKind::IK_Copy || Kind.isExplicitCast()) return Sema::OwningExprResult(S, Args.release()[0]); unsigned NumArgs = Args.size();