Switch compound literals over to InitializationSequence.

llvm-svn: 91882
This commit is contained in:
Eli Friedman 2009-12-22 02:35:53 +00:00
parent 463e523ad8
commit a553d4ac95
2 changed files with 10 additions and 3 deletions

View File

@ -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<Expr*>(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,

View File

@ -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();