summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 6a65bd1..d0f214f 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -873,8 +873,7 @@ static bool IsReturnCopyElidable(ASTContext &Ctx, QualType RetType,
if (!RetType->isRecordType())
return false;
// ... the same cv-unqualified type as the function return type ...
- if (Ctx.getCanonicalType(RetType).getUnqualifiedType() !=
- Ctx.getCanonicalType(ExprType).getUnqualifiedType())
+ if (!Ctx.hasSameUnqualifiedType(RetType, ExprType))
return false;
// ... the expression is the name of a non-volatile automatic object ...
// We ignore parentheses here.
@@ -965,9 +964,12 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
// In C++ the return statement is handled via a copy initialization.
// the C version of which boils down to CheckSingleAssignmentConstraints.
// FIXME: Leaks RetValExp on error.
- if (PerformCopyInitialization(RetValExp, FnRetType, "returning", Elidable))
+ if (PerformCopyInitialization(RetValExp, FnRetType, "returning", Elidable)){
+ // We should still clean up our temporaries, even when we're failing!
+ RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp, true);
return StmtError();
-
+ }
+
if (RetValExp) CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc);
}
OpenPOWER on IntegriCloud