diff options
author | Marek Polacek <polacek@redhat.com> | 2018-08-21 15:38:36 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-08-21 15:38:36 +0000 |
commit | 79ca9c3596a2de77d953cc84e31150051f4d2441 (patch) | |
tree | b04486ba9b0aaa7af7f595797d4939cc9fa32b38 /gcc/c-family | |
parent | 992931ba3d02d107b3abf51781b4b4625d2cce7c (diff) | |
download | gcc-79ca9c3596a2de77d953cc84e31150051f4d2441.zip gcc-79ca9c3596a2de77d953cc84e31150051f4d2441.tar.gz gcc-79ca9c3596a2de77d953cc84e31150051f4d2441.tar.bz2 |
PR c++/86981, Implement -Wpessimizing-move.
* c.opt (Wpessimizing-move): New option.
* typeck.c (decl_in_std_namespace_p): New.
(is_std_move_p): New.
(maybe_warn_pessimizing_move): New.
(can_do_nrvo_p): New, factored out of ...
(check_return_expr): ... here. Warn about potentially harmful
std::move in a return statement.
* doc/invoke.texi: Document -Wpessimizing-move.
* g++.dg/cpp0x/Wpessimizing-move1.C: New test.
* g++.dg/cpp0x/Wpessimizing-move2.C: New test.
* g++.dg/cpp0x/Wpessimizing-move3.C: New test.
* g++.dg/cpp0x/Wpessimizing-move4.C: New test.
* g++.dg/cpp1z/Wpessimizing-move1.C: New test.
From-SVN: r263741
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index aa52815..790df09 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2018-08-21 Marek Polacek <polacek@redhat.com> + + PR c++/86981, Implement -Wpessimizing-move. + * c.opt (Wpessimizing-move): New option. + 2018-08-20 David Malcolm <dmalcolm@redhat.com> PR other/84889 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 9980bfa..76840dd 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -937,6 +937,10 @@ Wpedantic C ObjC C++ ObjC++ CPP(cpp_pedantic) CppReason(CPP_W_PEDANTIC) Warning ; Documented in common.opt +Wpessimizing-move +C++ ObjC++ Var(warn_pessimizing_move) Warning LangEnabledBy(C++ ObjC++, Wall) +Warn about calling std::move on a local object in a return statement preventing copy elision. + Wpmf-conversions C++ ObjC++ Var(warn_pmf2ptr) Init(1) Warning Warn when converting the type of pointers to member functions. |