c++: implicit 'this' in noexcept-spec within class tmpl [PR94944]
authorPatrick Palka <ppalka@redhat.com>
Fri, 18 Feb 2022 01:20:24 +0000 (20:20 -0500)
committerPatrick Palka <ppalka@redhat.com>
Fri, 18 Feb 2022 01:20:24 +0000 (20:20 -0500)
commit36278f48cbc08c78e4ed588e5a049bd45fd1c55a
tree7014331020eb2e0adfd3cc00d2aa3cbe6f96e7b8
parent0bdb049877f405f361a9a3f597267ff5e44733a2
c++: implicit 'this' in noexcept-spec within class tmpl [PR94944]

Here when instantiating the noexcept-spec we fail to resolve the
implicit object for the member call A<T>::f() ultimately because
maybe_instantiate_noexcept sets current_class_ptr/ref to the dependent
'this' (of type B<T>) rather than the specialized 'this' (of type B<int>).

This patch fixes this by making maybe_instantiate_noexcept set
current_class_ptr/ref to the specialized 'this' instead, consistent
with what tsubst_function_type does when substituting into the trailing
return type of a non-static member function.

PR c++/94944

gcc/cp/ChangeLog:

* pt.cc (maybe_instantiate_noexcept): For non-static member
functions, set current_class_ptr/ref to the specialized 'this'
instead.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept34.C: Adjusted expected diagnostics.
* g++.dg/cpp0x/noexcept75.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp0x/noexcept34.C
gcc/testsuite/g++.dg/cpp0x/noexcept75.C [new file with mode: 0644]