Make sure we call MaybeCreateExprWithCleanups for the sub-expression of an indirect goto.

llvm-svn: 149441
This commit is contained in:
Eli Friedman 2012-01-31 22:47:07 +00:00
parent 87d3280985
commit 9ccdb1d01b
3 changed files with 9 additions and 0 deletions

View File

@ -1611,6 +1611,7 @@ Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc,
E = ExprRes.take();
if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E, AA_Passing))
return StmtError();
E = MaybeCreateExprWithCleanups(E);
}
getCurFunction()->setHasIndirectGoto();

View File

@ -5326,6 +5326,7 @@ TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
ExprResult Target = getDerived().TransformExpr(S->getTarget());
if (Target.isInvalid())
return StmtError();
Target = SemaRef.MaybeCreateExprWithCleanups(Target.take());
if (!getDerived().AlwaysRebuild() &&
Target.get() == S->getTarget())

View File

@ -0,0 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace test1 {
// Make sure this doesn't crash.
struct A { ~A(); };
void a() { goto *(A(), &&L); L: return; }
}