diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-11-18 14:59:57 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-11-18 14:59:57 +0000 |
commit | b3d5a323a5ca92ea73443499cee2f15db1ff0fb3 (patch) | |
tree | 60a1694bec5a44d15456acc880cb2f91619f66aa /lib/Sema/SemaStmt.cpp | |
parent | 8f57cb0305232cb53fff00ef151ca716766f3437 (diff) |
Notes
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 6a65bd1dd1ec8..d0f214fbd83dd 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); } |