c++: Failure to lookup using-decl name [PR98231]
authorMarek Polacek <polacek@redhat.com>
Wed, 13 Jan 2021 16:09:14 +0000 (11:09 -0500)
committerMarek Polacek <polacek@redhat.com>
Wed, 13 Jan 2021 22:16:30 +0000 (17:16 -0500)
commit796ead19f85372e59217c9888db688a2fe11b54f
tree827da19dae4cc952febf76f97a568e2b8ef5219f
parent8fc183ccd0628465205b8a88c29ab69bfe74a08a
c++: Failure to lookup using-decl name [PR98231]

In r11-4690 we removed the call to finish_nonmember_using_decl in
tsubst_expr/DECL_EXPR in the USING_DECL block.  This was done not
to perform name lookup twice for a non-dependent using-decl, which
sounds sensible.

However, finish_nonmember_using_decl also pushes the decl's bindings
which we still have to do so that we can find the USING_DECL's name
later.  In this case, we've got a USING_DECL N::operator<<  that we are
tsubstituting.  We already looked it up while parsing the template
"foo", and lookup_using_decl stashed the OVERLOAD it found into
USING_DECL_DECLS.  Now we just have to update the IDENTIFIER_BINDING of
the identifier for operator<< with the overload the name is bound to.

I didn't want to export push_local_binding so I've introduced a new
wrapper.

gcc/cp/ChangeLog:

PR c++/98231
* name-lookup.c (push_using_decl_bindings): New.
* name-lookup.h (push_using_decl_bindings): Declare.
* pt.c (tsubst_expr): Call push_using_decl_bindings.

gcc/testsuite/ChangeLog:

PR c++/98231
* g++.dg/lookup/using63.C: New test.
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h
gcc/cp/pt.c
gcc/testsuite/g++.dg/lookup/using63.C [new file with mode: 0644]