Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Sema/SemaStmt.cpp
Show First 20 Lines • Show All 3,647 Lines • ▼ Show 20 Lines | if (FnRetType->isDependentType()) { | ||||
// we have a non-void block with an expression, continue checking | // we have a non-void block with an expression, continue checking | ||||
// C99 6.8.6.4p3(136): The return statement is not an assignment. The | // C99 6.8.6.4p3(136): The return statement is not an assignment. The | ||||
// overlap restriction of subclause 6.5.16.1 does not apply to the case of | // overlap restriction of subclause 6.5.16.1 does not apply to the case of | ||||
// function return. | // function return. | ||||
// In C++ the return statement is handled via a copy initialization. | // In C++ the return statement is handled via a copy initialization. | ||||
// the C version of which boils down to CheckSingleAssignmentConstraints. | // the C version of which boils down to CheckSingleAssignmentConstraints. | ||||
InitializedEntity Entity = InitializedEntity::InitializeResult( | InitializedEntity Entity = | ||||
ReturnLoc, FnRetType, NRVOCandidate != nullptr); | InitializedEntity::InitializeResult(ReturnLoc, FnRetType); | ||||
ExprResult Res = PerformMoveOrCopyInitialization( | ExprResult Res = PerformMoveOrCopyInitialization( | ||||
Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves); | Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves); | ||||
if (Res.isInvalid()) { | if (Res.isInvalid()) { | ||||
// FIXME: Cleanup temporaries here, anyway? | // FIXME: Cleanup temporaries here, anyway? | ||||
return StmtError(); | return StmtError(); | ||||
} | } | ||||
RetValExp = Res.get(); | RetValExp = Res.get(); | ||||
CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc); | CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc); | ||||
▲ Show 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | if (FnRetType->isVoidType()) { | ||||
// C99 6.8.6.4p3(136): The return statement is not an assignment. The | // C99 6.8.6.4p3(136): The return statement is not an assignment. The | ||||
// overlap restriction of subclause 6.5.16.1 does not apply to the case of | // overlap restriction of subclause 6.5.16.1 does not apply to the case of | ||||
// function return. | // function return. | ||||
// In C++ the return statement is handled via a copy initialization, | // In C++ the return statement is handled via a copy initialization, | ||||
// the C version of which boils down to CheckSingleAssignmentConstraints. | // the C version of which boils down to CheckSingleAssignmentConstraints. | ||||
if (!HasDependentReturnType && !RetValExp->isTypeDependent()) { | if (!HasDependentReturnType && !RetValExp->isTypeDependent()) { | ||||
// we have a non-void function with an expression, continue checking | // we have a non-void function with an expression, continue checking | ||||
InitializedEntity Entity = InitializedEntity::InitializeResult( | InitializedEntity Entity = | ||||
ReturnLoc, RetType, NRVOCandidate != nullptr); | InitializedEntity::InitializeResult(ReturnLoc, RetType); | ||||
ExprResult Res = PerformMoveOrCopyInitialization( | ExprResult Res = PerformMoveOrCopyInitialization( | ||||
Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves); | Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves); | ||||
if (Res.isInvalid()) { | if (Res.isInvalid()) { | ||||
// FIXME: Clean up temporaries here anyway? | // FIXME: Clean up temporaries here anyway? | ||||
return StmtError(); | return StmtError(); | ||||
} | } | ||||
RetValExp = Res.getAs<Expr>(); | RetValExp = Res.getAs<Expr>(); | ||||
▲ Show 20 Lines • Show All 665 Lines • Show Last 20 Lines |