c++: result location and explicit inst [PR108496]
commit4b125d01a5d5e601961419396332b74eea2219bb
authorJason Merrill <jason@redhat.com>
Mon, 23 Jan 2023 18:33:07 +0000 (23 13:33 -0500)
committerJason Merrill <jason@redhat.com>
Mon, 23 Jan 2023 19:09:49 +0000 (23 14:09 -0500)
treebc3c5e4f498cd73dfdada1262cbd180a8708b13f
parentc3c6c307792026705fe0398f5ee399f7668fed1b
c++: result location and explicit inst [PR108496]

In r13-4469 we started to build the RESULT_DECL in grokdeclarator, while we
still know the location of the return type.  But in this testcase, we hit
that code again when parsing the explicit instantiation, and clobber the
DECL_RESULT that was previously used in parsing the function.  So, only set
DECL_RESULT if it isn't already set.

PR c++/108496

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator): Check whether DECL_RESULT is already
set.

gcc/testsuite/ChangeLog:

* g++.dg/template/explicit-instantiation5.C: New test.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/template/explicit-instantiation5.C [new file with mode: 0644]