diff options
author | Marek Polacek <polacek@redhat.com> | 2022-08-01 17:02:23 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2022-08-17 12:35:45 -0400 |
commit | 8d22c7cb8b1a6f9b67c54a798dd5504244614e51 (patch) | |
tree | 1c20cb245dd1cdb66727bde28f86ce9850e5e056 /gcc/graphite-optimize-isl.cc | |
parent | 745be54bd6634fe63d6be83615e264c83d2ae9f9 (diff) | |
download | gcc-8d22c7cb8b1a6f9b67c54a798dd5504244614e51.zip gcc-8d22c7cb8b1a6f9b67c54a798dd5504244614e51.tar.gz gcc-8d22c7cb8b1a6f9b67c54a798dd5504244614e51.tar.bz2 |
c++: Extend -Wpessimizing-move to other contexts
In my recent patch which enhanced -Wpessimizing-move so that it warns
about class prvalues too I said that I'd like to extend it so that it
warns in more contexts where a std::move can prevent copy elision, such
as:
T t = std::move(T());
T t(std::move(T()));
T t{std::move(T())};
T t = {std::move(T())};
void foo (T);
foo (std::move(T()));
This patch does that by adding two maybe_warn_pessimizing_move calls.
These must happen before we've converted the initializers otherwise the
std::move will be buried in a TARGET_EXPR.
PR c++/106276
gcc/cp/ChangeLog:
* call.cc (build_over_call): Call maybe_warn_pessimizing_move.
* cp-tree.h (maybe_warn_pessimizing_move): Declare.
* decl.cc (build_aggr_init_full_exprs): Call
maybe_warn_pessimizing_move.
* typeck.cc (maybe_warn_pessimizing_move): Handle TREE_LIST and
CONSTRUCTOR. Add a bool parameter and use it. Adjust a diagnostic
message.
(check_return_expr): Adjust the call to maybe_warn_pessimizing_move.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/Wpessimizing-move7.C: Add dg-warning.
* g++.dg/cpp0x/Wpessimizing-move8.C: New test.
Diffstat (limited to 'gcc/graphite-optimize-isl.cc')
0 files changed, 0 insertions, 0 deletions