If any errors have occurred by the time we hit the end of a function body, clear out any remaining temporaries so they aren't seen later.

llvm-svn: 88834
This commit is contained in:
Douglas Gregor 2009-11-15 07:07:58 +00:00
parent b9bbd54fdb
commit a7e3ea3f64
1 changed files with 6 additions and 0 deletions

View File

@ -4026,6 +4026,12 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(dcl))
computeBaseOrMembersToDestroy(Destructor);
// If any errors have occurred, clear out any temporaries that may have
// been leftover. This ensures that these temporaries won't be picked up for
// deletion in some later function.
if (PP.getDiagnostics().hasErrorOccurred())
ExprTemporaries.clear();
assert(ExprTemporaries.empty() && "Leftover temporaries in function");
return D;
}