diff options
author | Patrick Palka <ppalka@redhat.com> | 2023-05-19 09:40:16 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2023-05-19 09:40:16 -0400 |
commit | ef8926d23a458560b8e9be1a76cf29ddcb87ec2a (patch) | |
tree | 59d7ad52b8178661fff88fd23e25ee1d41a95729 /gcc/cp/constraint.cc | |
parent | e430b32528d03fc655142525793639f6aeb31590 (diff) | |
download | gcc-ef8926d23a458560b8e9be1a76cf29ddcb87ec2a.zip gcc-ef8926d23a458560b8e9be1a76cf29ddcb87ec2a.tar.gz gcc-ef8926d23a458560b8e9be1a76cf29ddcb87ec2a.tar.bz2 |
c++: scoped variable template-id of reference type [PR97340]
lookup_and_finish_template_variable calls convert_from_reference, which
means for a variable template-id of reference type the function wraps
the corresponding VAR_DECL in an INDIRECT_REF. But the downstream logic
of two callers, tsubst_qualified_id and finish_class_member_access_expr,
expect a DECL_P result and this unexpected INDIRECT_REF leads to an ICE
resolving such a (dependently scoped) template-id as in the first testcase.
(Note these two callers eventually call convert_from_reference on the
result anyway, so calling it earlier seems redundant in this case.)
This patch fixes this by pulling out the convert_from_reference call
from lookup_and_finish_template_variable and into the callers that
actually need it, which turns out to only be tsubst_copy_and_build
(if we got rid of the call there we'd mishandle the second testcase).
PR c++/97340
gcc/cp/ChangeLog:
* pt.cc (lookup_and_finish_template_variable): Don't call
convert_from_reference.
(tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Call
convert_from_reference on the result of
lookup_and_finish_template_variable.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/var-templ80.C: New test.
* g++.dg/cpp1y/var-templ81.C: New test.
Diffstat (limited to 'gcc/cp/constraint.cc')
0 files changed, 0 insertions, 0 deletions