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.