]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: DMI in template with virtual base [PR106890]
authorJason Merrill <jason@redhat.com>
Sat, 18 Mar 2023 12:27:26 +0000 (08:27 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 18 Apr 2023 20:44:28 +0000 (16:44 -0400)
commit94569d91bd4c604da755b4aae84256e7fe21196a
treea3bebc74e35b9cf9a3917063d27fdfc977bfb12e
parent55ab4606ab1084a55d53184c5cf4543740a7f65d
c++: DMI in template with virtual base [PR106890]

When parsing a default member init we just build a CONVERT_EXPR for
converting to a virtual base, and then expand that into the more complex
form when we actually use the DMI in a constructor.  But that wasn't working
for the template case where we are considering the conversion at the point
that the constructor needs the DMI instantiation, so it seemed like we were
in a constructor already.  And then when the other constructor tries to
reuse the instantiation, it sees uses of the first constructor's parameters,
and dies.  So ensure that we get the CONVERT_EXPR in this case, too.

PR c++/106890

gcc/cp/ChangeLog:

* init.cc (maybe_instantiate_nsdmi_init): Don't leave
current_function_decl set to a constructor.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nsdmi-template25.C: New test.
gcc/cp/init.cc
gcc/testsuite/g++.dg/cpp0x/nsdmi-template25.C [new file with mode: 0644]