]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: erroneous partial spec vs primary tmpl [PR116064]
authorPatrick Palka <ppalka@redhat.com>
Wed, 7 Aug 2024 18:28:26 +0000 (14:28 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 7 Aug 2024 18:28:26 +0000 (14:28 -0400)
commitd1fc9816df81e953308428641685d6ec6d84c9ac
treee342a3153f56d165ce51abc9d55e55a01b79655a
parent38900247f3880d6eca2e364a000e5898f8deae64
c++: erroneous partial spec vs primary tmpl [PR116064]

When a partial specialization is deemed erroneous at parse time, we
currently flag the primary template as erroneous instead.  Later
at instantiation time we check if the primary template is erroneous
rather than the selected partial specialization, so at least we're
consistent.

But it's better not to conflate a partial specialization with the
primary template since they're instantiated independenty.  This avoids
rejecting the instantiation of A<int> in the below testcase.

PR c++/116064

gcc/cp/ChangeLog:

* error.cc (get_current_template): If the current scope is
a partial specialization, return it instead of the primary
template.
* pt.cc (instantiate_class_template): Pass the partial
specialization if any to maybe_diagnose_erroneous_template
instead of the primary template.

gcc/testsuite/ChangeLog:

* g++.dg/template/permissive-error2.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/error.cc
gcc/cp/pt.cc
gcc/testsuite/g++.dg/template/permissive-error2.C [new file with mode: 0644]