c++: improved return expression location
authorJason Merrill <jason@redhat.com>
Fri, 19 Nov 2021 22:01:10 +0000 (17:01 -0500)
committerJason Merrill <jason@redhat.com>
Mon, 22 Nov 2021 22:42:53 +0000 (17:42 -0500)
commit5440c88e61f5c624eb87e19801eef6eedf27e8ab
treec5ede3ce9a981ca2934d5a24df4b7102c8ef5e42
parenta6e0d593707ae44dec0bdf2bcdc4f539050b46db
c++: improved return expression location

Stripping the location wrapper from retval meant we didn't have the
necessary location information for any conversion diagnostics.  We only need
the stripping for the named return value optimization, let's use the
unstripped expression for everything else.

gcc/cp/ChangeLog:

* typeck.c (check_return_expr): Only strip location wrapper during
NRV handling.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/pr65327.C: Adjust location.
* g++.dg/cpp23/constexpr-nonlit4.C: Likewise.
* g++.dg/cpp23/constexpr-nonlit5.C: Likewise.
* g++.dg/cpp2a/constexpr-init1.C: Likewise.
gcc/cp/typeck.c
gcc/testsuite/g++.dg/cpp0x/pr65327.C
gcc/testsuite/g++.dg/cpp23/constexpr-nonlit4.C
gcc/testsuite/g++.dg/cpp23/constexpr-nonlit5.C
gcc/testsuite/g++.dg/cpp2a/constexpr-init1.C