c++: More set_identifier_type_value fixing [PR 99116]
authorNathan Sidwell <nathan@acm.org>
Wed, 17 Feb 2021 13:33:45 +0000 (05:33 -0800)
committerNathan Sidwell <nathan@acm.org>
Wed, 17 Feb 2021 13:41:37 +0000 (05:41 -0800)
commit24bf79f1798ad1d64812709001d2d11cd3e6849f
treec7501157810903d8c2a6afae46e2d83fb0542469
parentd46c7e2c546b26d036856cf570694b832d3b1f54
c++: More set_identifier_type_value fixing [PR 99116]

My recent change looked under template_parms in two places, but that
was covering up a separate problem.  We were attempting to set the
identifier_type_value of a template_parm into the template_parm
scope.  The peeking stopped us doing that, but confused poplevel,
leaving an identifier value lying around.  This fixes the underlying
problem in do_pushtag -- we only need to set the identifier_type_value
directly when we're in a template_parm scope (a later pushdecl will
push the actual template_decl).  for non-class non-template-parm
bindings do_pushdecl already ends up manipulating
identifier_type_value correctly.

PR c++/99116
gcc/cp/
* name-lookup.c (do_pushdecl): Don't peek under template_parm
bindings here ...
(set_identifier_type_value_with_scope): ... or here.
(do_pushtag): Only set_identifier_type_value_with_scope at
non-class template parm scope, and use parent scope.
gcc/testsuite/
* g++.dg/lookup/pr99116-1.C: New.
* g++.dg/lookup/pr99116-2.C: New.
gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/lookup/pr99116-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lookup/pr99116-2.C [new file with mode: 0644]