c++: Fix ICE from op_unqualified_lookup [PR97582]
authorPatrick Palka <ppalka@redhat.com>
Thu, 11 Feb 2021 15:59:54 +0000 (10:59 -0500)
committerPatrick Palka <ppalka@redhat.com>
Thu, 11 Feb 2021 15:59:54 +0000 (10:59 -0500)
commitcb168f779c87c1e0c37d22ea82dfb93ff8c873bc
tree16f4421193ce9ad7b934fa31438a98757cd4d93f
parent38c5703449c0638618ba6896f0d039c3868ad4e0
c++: Fix ICE from op_unqualified_lookup [PR97582]

In this testcase, we're crashing because the lookup of operator+ from
within the generic lambda via lookup_name finds multiple bindings
(C1::operator+ and C2::operator+) and returns a TREE_LIST thereof,
something which op_unqualified_lookup (and push_operator_bindings) isn't
prepared to handle.

This patch extends op_unqualified_lookup and push_operator_bindings
to handle such an ambiguous lookup result in the natural way.

gcc/cp/ChangeLog:

PR c++/97582
* name-lookup.c (op_unqualified_lookup): Handle an ambiguous
lookup result by discarding it if the first element is a
class-scope declaration, otherwise return it.
(push_operator_bindings): Handle an ambiguous lookup result by
doing push_local_binding on each element in the list.

gcc/testsuite/ChangeLog:

PR c++/97582
* g++.dg/cpp0x/lambda/lambda-template17.C: New test.
gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template17.C [new file with mode: 0644]