Commit b6d846de by Jason Merrill Committed by Jason Merrill

re PR c++/57901 (Cannot call-by-value such that class has non-trivial (constexpr) move constructor)

	PR c++/57901
	* semantics.c (build_data_member_initialization, constexpr_fn_retval):
	Use break_out_target_exprs instead of unshare_expr.

From-SVN: r201338
parent 1b798a0f
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
......
......@@ -6016,7 +6016,7 @@ build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec)
|| 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)
{
......@@ -6024,7 +6024,7 @@ build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec)
/* 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. */
......@@ -6261,7 +6261,7 @@ constexpr_fn_retval (tree body)
}
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)
......
// 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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment