+2013-07-29 Jason Merrill <jason@redhat.com>
+
+ PR c++/57901
+ * semantics.c (build_data_member_initialization, constexpr_fn_retval):
+ Use break_out_target_exprs instead of unshare_expr.
+
2013-07-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57948
|| TREE_CODE (t) == MODIFY_EXPR)
{
member = TREE_OPERAND (t, 0);
- init = unshare_expr (TREE_OPERAND (t, 1));
+ init = break_out_target_exprs (TREE_OPERAND (t, 1));
}
else if (TREE_CODE (t) == CALL_EXPR)
{
/* We don't use build_cplus_new here because it complains about
abstract bases. Leaving the call unwrapped means that it has the
wrong type, but cxx_eval_constant_expression doesn't care. */
- init = unshare_expr (t);
+ init = break_out_target_exprs (t);
}
else if (TREE_CODE (t) == DECL_EXPR)
/* Declaring a temporary, don't add it to the CONSTRUCTOR. */
}
case RETURN_EXPR:
- return unshare_expr (TREE_OPERAND (body, 0));
+ return break_out_target_exprs (TREE_OPERAND (body, 0));
case DECL_EXPR:
if (TREE_CODE (DECL_EXPR_DECL (body)) == USING_DECL)
--- /dev/null
+// PR c++/57901
+// { dg-require-effective-target c++11 }
+
+struct Z {
+ Z() = default;
+ Z(Z const&) = default;
+ constexpr Z(Z&&) {} /* non-trivial (constexpr) move ctor */
+};
+
+template<typename T>
+constexpr int fn0(T v) { return 0; }
+template<typename T>
+constexpr int fn (T v) { return fn0(v); }
+
+constexpr auto t0 = fn0(Z()); // OK!
+constexpr auto t = fn (Z()); // error! (GCC 4.8.1)