2019-03-12 Jakub Jelinek PR c++/89660 Revert: 2019-03-06 Marek Polacek PR c++/87378 - bogus -Wredundant-move warning. * typeck.c (maybe_warn_pessimizing_move): See if the maybe-rvalue overload resolution would actually succeed. * g++.dg/cpp0x/Wredundant-move1.C (fn4): Drop dg-warning. --- gcc/cp/typeck.c (revision 269427) +++ gcc/cp/typeck.c (revision 269426) @@ -9429,24 +9429,10 @@ maybe_warn_pessimizing_move (tree retval do maybe-rvalue overload resolution even without std::move. */ else if (treat_lvalue_as_rvalue_p (arg, /*parm_ok*/true)) { - /* Make sure that the overload resolution would actually succeed - if we removed the std::move call. */ - tree t = convert_for_initialization (NULL_TREE, functype, - move (arg), - (LOOKUP_NORMAL - | LOOKUP_ONLYCONVERTING - | LOOKUP_PREFER_RVALUE), - ICR_RETURN, NULL_TREE, 0, - tf_none); - /* If this worked, implicit rvalue would work, so the call to - std::move is redundant. */ - if (t != error_mark_node) - { - auto_diagnostic_group d; - if (warning_at (loc, OPT_Wredundant_move, - "redundant move in return statement")) - inform (loc, "remove % call"); - } + auto_diagnostic_group d; + if (warning_at (loc, OPT_Wredundant_move, + "redundant move in return statement")) + inform (loc, "remove % call"); } } } --- gcc/testsuite/g++.dg/cpp0x/Wredundant-move1.C (revision 269427) +++ gcc/testsuite/g++.dg/cpp0x/Wredundant-move1.C (revision 269426) @@ -59,8 +59,7 @@ T fn4 (const T t) { // t is const: will decay into copy despite std::move, so it's redundant. - // We used to warn about this, but no longer since c++/87378. - return std::move (t); + return std::move (t); // { dg-warning "redundant move in return statement" } } int