From: Marek Polacek Date: Sun, 26 Aug 2018 16:31:27 +0000 (+0000) Subject: re PR c++/87080 (ice in cp_get_fndecl_from_callee, at cp/cvt.c:965) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0940fe595548ec397ffdb6c2f8fa4392c1c15ec5;p=gcc.git re PR c++/87080 (ice in cp_get_fndecl_from_callee, at cp/cvt.c:965) PR c++/87080 * typeck.c (maybe_warn_pessimizing_move): Do nothing in a template. * g++.dg/cpp0x/Wpessimizing-move5.C: New test. From-SVN: r263862 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ccb771b2785..258c6a9b763 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-08-26 Marek Polacek + + PR c++/87080 + * typeck.c (maybe_warn_pessimizing_move): Do nothing in a template. + 2018-08-24 Marek Polacek PR c++/67012 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 122d9dcd4b3..24647e29a55 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -9192,6 +9192,11 @@ maybe_warn_pessimizing_move (tree retval, tree functype) if (cxx_dialect < cxx11) return; + /* Wait until instantiation time, since we can't gauge if we should do + the NRVO until then. */ + if (processing_template_decl) + return; + /* This is only interesting for class types. */ if (!CLASS_TYPE_P (functype)) return; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 67f4cdedbb0..3bd02e71eed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-26 Marek Polacek + + PR c++/87080 + * g++.dg/cpp0x/Wpessimizing-move5.C: New test. + 2018-08-25 Thomas Koenig PR libfortran/86704 diff --git a/gcc/testsuite/g++.dg/cpp0x/Wpessimizing-move5.C b/gcc/testsuite/g++.dg/cpp0x/Wpessimizing-move5.C new file mode 100644 index 00000000000..02ad2113505 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wpessimizing-move5.C @@ -0,0 +1,14 @@ +// PR c++/87080 +// { dg-do compile { target c++11 } } +// { dg-options "-Wpessimizing-move" } + +struct a { + template a &operator<<(b); +}; +a c(); +template +a fn2() +{ + int d = 42; + return c() << d; +}