c++: non-dependent variable template-id [PR108848]
authorPatrick Palka <ppalka@redhat.com>
Tue, 28 Feb 2023 20:05:30 +0000 (15:05 -0500)
committerPatrick Palka <ppalka@redhat.com>
Tue, 28 Feb 2023 20:05:30 +0000 (15:05 -0500)
commitd3d205ab440886164b6de2be2a2efa10cac95b66
tree5ed37246db4303d50f761537d738fc751b2c5e6f
parentafe6cea4489846aa8585f3c045d16cdaa08cc6cd
c++: non-dependent variable template-id [PR108848]

Here we're treating deeming the non-dependent variable template-id
tag<int> as dependent ever since r226642 gave variable TEMPLATE_ID_EXPR
an empty type, which causes the call to finish_template_variable from
finish_id_expression_1 to be unreachable at template parse time.  Thus
we're led into thinking tag<int>.var<void> refers to a dependent name.

This patch fixes this by making finish_id_expression_1 instantiate a
variable template-id as long as it's not dependent according to the
dependence test in lookup_and_finish_template_variable rather than
according to type_dependent_expression_p.

PR c++/108848

gcc/cp/ChangeLog:

* pt.cc (finish_template_variable): Move dependence check
to here from ...
(lookup_and_finish_template_variable): ... here.
* semantics.cc (finish_id_expression_1): Call
finish_template_variable sooner, before (and regardless of) the
type_dependent_expression_p test.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/noexcept1.C: Don't expect a bogus "different
exception specifier" error.  Expect a separate "not usable
in a constant expression" error.
* g++.dg/cpp1y/var-templ75.C: New test.
* g++.dg/cpp1y/var-templ76.C: New test.
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/cpp1y/noexcept1.C
gcc/testsuite/g++.dg/cpp1y/var-templ75.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/var-templ76.C [new file with mode: 0644]