2016-10-05 Jason Merrill <jason@redhat.com>
+ Implement P0135R1, Guaranteed copy elision.
+ * cvt.c (ocp_convert): Don't re-copy a TARGET_EXPR in C++17.
+
PR c++/54293
* call.c (reference_binding): Fix binding to member of temporary.
if (error_operand_p (e))
return error_mark_node;
- if (MAYBE_CLASS_TYPE_P (type) && (convtype & CONV_FORCE_TEMP))
- /* We need a new temporary; don't take this shortcut. */;
+ if (MAYBE_CLASS_TYPE_P (type) && (convtype & CONV_FORCE_TEMP)
+ && !(cxx_dialect >= cxx1z
+ && TREE_CODE (e) == TARGET_EXPR))
+ /* We need a new temporary; don't take this shortcut. But in C++17, don't
+ force a temporary if we already have one. */;
else if (same_type_ignoring_top_level_qualifiers_p (type, TREE_TYPE (e)))
{
if (same_type_p (type, TREE_TYPE (e)))