Here gimplification got confused because extend_temps_r messed up the types
of the arms of a COND_EXPR.
PR c++/119073
gcc/cp/ChangeLog:
* call.cc (extend_temps_r): Preserve types of COND_EXPR arms.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/range-for39.C: New test.
{
tree set = build2 (MODIFY_EXPR, boolean_type_node,
cur_cond_guard, boolean_true_node);
- op = add_stmt_to_compound (set, op);
+ op = cp_build_compound_expr (set, op, tf_none);
}
};
walk_arm (TREE_OPERAND (*tp, 1));
--- /dev/null
+// PR c++/119073
+// { dg-do compile { target c++11 } }
+
+struct A { ~A (); };
+struct B { B (const A &a = A ()); int *begin (); int *end (); ~B (); };
+
+void
+foo (bool x)
+{
+ for (auto i : (x ? B{} : B{}))
+ ;
+}