aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-path.cc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2022-08-17 13:36:52 -0400
committerMarek Polacek <polacek@redhat.com>2022-08-17 13:36:52 -0400
commit6c136d53e89e32fe9d22e41e5df89c08d3470049 (patch)
tree99a2a10d5bd94b903952239db63a15fe0a3c4201 /gcc/gimple-range-path.cc
parent6602a2b2dee16af6e2d451c704789356042b5881 (diff)
downloadgcc-6c136d53e89e32fe9d22e41e5df89c08d3470049.zip
gcc-6c136d53e89e32fe9d22e41e5df89c08d3470049.tar.gz
gcc-6c136d53e89e32fe9d22e41e5df89c08d3470049.tar.bz2
c++: Extend -Wredundant-move for const-qual objects [PR90428]
In this PR, Jon suggested extending the -Wredundant-move warning to warn when the user is moving a const object as in: struct T { }; T f(const T& t) { return std::move(t); } where the std::move is redundant, because T does not have a T(const T&&) constructor (which is very unlikely). Even with the std::move, T(T&&) would not be used because it would mean losing the const. Instead, T(const T&) will be called. I had to restructure the function a bit, but it's better now. This patch depends on my other recent patches to maybe_warn_pessimizing_move. PR c++/90428 gcc/cp/ChangeLog: * typeck.cc (can_do_rvo_p): Rename to ... (can_elide_copy_prvalue_p): ... this. (maybe_warn_pessimizing_move): Extend the -Wredundant-move warning to warn about std::move on a const-qualified object. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/Wredundant-move1.C: Adjust dg-warning. * g++.dg/cpp0x/Wredundant-move9.C: Likewise. * g++.dg/cpp0x/Wredundant-move10.C: New test.
Diffstat (limited to 'gcc/gimple-range-path.cc')
0 files changed, 0 insertions, 0 deletions