[Bug c++/87029] Add -Wredundant-move warning

2018-08-26 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87029

Marek Polacek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Marek Polacek  ---
Implemented for GCC 9.  This warning should still be extended to handle
initializers, where the std::move can also be redundant.

[Bug c++/87029] Add -Wredundant-move warning

2018-08-26 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87029

--- Comment #3 from Marek Polacek  ---
Author: mpolacek
Date: Sun Aug 26 16:45:51 2018
New Revision: 263863

URL: https://gcc.gnu.org/viewcvs?rev=263863&root=gcc&view=rev
Log:
PR c++/87029, Implement -Wredundant-move.
* c.opt (Wredundant-move): New option.

* typeck.c (treat_lvalue_as_rvalue_p): New function.
(maybe_warn_pessimizing_move): Call convert_from_reference.
Warn about redundant moves.

* doc/invoke.texi: Document -Wredundant-move.

* g++.dg/cpp0x/Wredundant-move1.C: New test.
* g++.dg/cpp0x/Wredundant-move2.C: New test.
* g++.dg/cpp0x/Wredundant-move3.C: New test.
* g++.dg/cpp0x/Wredundant-move4.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/Wredundant-move1.C
trunk/gcc/testsuite/g++.dg/cpp0x/Wredundant-move2.C
trunk/gcc/testsuite/g++.dg/cpp0x/Wredundant-move3.C
trunk/gcc/testsuite/g++.dg/cpp0x/Wredundant-move4.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c.opt
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog

[Bug c++/87029] Add -Wredundant-move warning

2018-08-20 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87029

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=86981,
   ||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=67906,
   ||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=81159

--- Comment #2 from Eric Gallager  ---
See also: bug 67906 and bug 81159

[Bug c++/87029] Add -Wredundant-move warning

2018-08-20 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87029

Marek Polacek  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2018-08-20
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org
Summary|Add -Wredundant-move|Add -Wredundant-move
   ||warning
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
This should be a fairly easy extension of -Wpessimizing-move.