A couple minor fixes to template instantiation for for-range loops.
llvm-svn: 149440
This commit is contained in:
parent
a223401498
commit
87d3280985
|
@ -5738,10 +5738,18 @@ TreeTransform<Derived>::TransformCXXForRangeStmt(CXXForRangeStmt *S) {
|
|||
ExprResult Cond = getDerived().TransformExpr(S->getCond());
|
||||
if (Cond.isInvalid())
|
||||
return StmtError();
|
||||
if (Cond.get())
|
||||
Cond = SemaRef.CheckBooleanCondition(Cond.take(), S->getColonLoc());
|
||||
if (Cond.isInvalid())
|
||||
return StmtError();
|
||||
if (Cond.get())
|
||||
Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.take());
|
||||
|
||||
ExprResult Inc = getDerived().TransformExpr(S->getInc());
|
||||
if (Inc.isInvalid())
|
||||
return StmtError();
|
||||
if (Inc.get())
|
||||
Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.take());
|
||||
|
||||
StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
|
||||
if (LoopVar.isInvalid())
|
||||
|
|
|
@ -158,3 +158,14 @@ namespace test2 {
|
|||
for (int x : a.xs) { } // expected-error {{'xs' is a private member of 'test2::A'}}
|
||||
}
|
||||
}
|
||||
|
||||
namespace test3 {
|
||||
// Make sure this doesn't crash
|
||||
struct A {};
|
||||
struct B { ~B(); operator bool(); };
|
||||
struct C { B operator!=(const C&); C& operator++(); int operator*(); };
|
||||
C begin(const A&);
|
||||
C end(const A&);
|
||||
template<typename T> void f() { for (auto a : A()) {} }
|
||||
void g() { f<int>(); }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue