diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cddf169ea5b..764b9ccffa3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-24 Jason Merrill + + PR c++/93279 - ICE with lambda in member operator. + * name-lookup.c (maybe_save_operator_binding): Don't remember + class-scope bindings. + 2020-01-24 Jason Merrill PR c++/93377 - ICE with member alias in constraint. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index cd7a5816e46..572100766cb 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -7616,6 +7616,12 @@ maybe_save_operator_binding (tree e) if (!fns && (fns = op_unqualified_lookup (fnname))) { + tree fn = get_first_fn (fns); + if (DECL_CLASS_SCOPE_P (fn)) + /* We don't need to remember class-scope functions, normal unqualified + lookup will find them again. */ + return; + bindings = tree_cons (fnname, fns, bindings); if (attr) TREE_VALUE (attr) = bindings; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template16.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template16.C new file mode 100644 index 00000000000..faaff68b968 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template16.C @@ -0,0 +1,15 @@ +// PR c++/93279 +// { dg-do compile { target c++11 } } + +template struct B { using f = int; }; +template struct E { + template ::f = 0> + void operator*(U l) { [l](T m) { m * l; }; } +}; + +int +main () +{ + E, 1> n; + n * 4.f; +}