]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: -Wdangling-reference not suppressed in template [PR109774]
authorMarek Polacek <polacek@redhat.com>
Tue, 16 May 2023 18:12:06 +0000 (14:12 -0400)
committerMarek Polacek <polacek@redhat.com>
Tue, 16 May 2023 18:12:57 +0000 (14:12 -0400)
commitf25d2de17663a0132f9fe090dee39d3b1132067b
tree681b675081c8a818c2ebc03bcd6f557327ecb288
parent94a311abf783de754f0f1b2d4c1f00a9788e795b
c++: -Wdangling-reference not suppressed in template [PR109774]

In check_return_expr, we suppress the -Wdangling-reference warning when
we're sure it would be a false positive.  It wasn't working in a
template, though, because the suppress_warning call was never reached.

PR c++/109774

gcc/cp/ChangeLog:

* typeck.cc (check_return_expr): In a template, return only after
suppressing -Wdangling-reference.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wdangling-reference13.C: New test.
gcc/cp/typeck.cc
gcc/testsuite/g++.dg/warn/Wdangling-reference13.C [new file with mode: 0644]