]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: recursive template with deduced return [PR120555]
authorJason Merrill <jason@redhat.com>
Fri, 6 Jun 2025 14:26:28 +0000 (10:26 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 6 Jun 2025 19:43:47 +0000 (15:43 -0400)
commit8d204f2a536f7253e4251aca7bc12af524800b4c
treed424f7d0875c17bbc8467fe7ba8113206cce60f9
parent37fe7e7069c2bb999c95a9807a8f895f38b9cacf
c++: recursive template with deduced return [PR120555]

Here since r15-4120 we were prematurely complaining about the use of func
within its own definiton, which is fine at instantiation time.  So don't
require this for function templates that are currently being defined.

But keep the error for instantiations of templates that are not currently
being defined, which we similarly did not diagnose before r15-4120 but other
implementations do.

Both of these follow the general principle from [temp.res.general]/6 that we
only error in a template body if no instatiation could be well-formed.

Also remove a redundant call to require_deduced_type.

PR c++/120555

gcc/cp/ChangeLog:

* decl2.cc (fn_being_defined, fn_template_being_defined): New.
(mark_used): Check fn_template_being_defined.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/constexpr-if39.C: New test.
gcc/cp/decl2.cc
gcc/testsuite/g++.dg/cpp1z/constexpr-if39.C [new file with mode: 0644]