diff options
author | Jason Merrill <jason@redhat.com> | 2020-01-24 18:20:56 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-01-24 22:18:46 -0500 |
commit | 8b91e848130e45b427599ad30e99f96e447ea9aa (patch) | |
tree | 851e36138628752ac727b597064877aeb0d5eabb /gcc | |
parent | c671727004b87f0f256191c3a99c50dc4888e79b (diff) | |
download | gcc-8b91e848130e45b427599ad30e99f96e447ea9aa.zip gcc-8b91e848130e45b427599ad30e99f96e447ea9aa.tar.gz gcc-8b91e848130e45b427599ad30e99f96e447ea9aa.tar.bz2 |
c++: Fix ICE with lambda in member operator (PR93279)
Here the problem was that we were remembering the lookup in template scope,
and then trying to reuse that lookup in the instantiation without
substituting into it at all. The simplest solution is to not try to
remember a lookup that finds a class-scope declaration, as in that case
doing the normal lookup again at instantiation time will always find the
right declarations.
PR c++/93279 - ICE with lambda in member operator.
* name-lookup.c (maybe_save_operator_binding): Don't remember
class-scope bindings.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template16.C | 15 |
3 files changed, 27 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cddf169..764b9cc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2020-01-24 Jason Merrill <jason@redhat.com> + 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 <jason@redhat.com> + PR c++/93377 - ICE with member alias in constraint. * pt.c (any_template_parm_r): Look at template arguments for all aliases, not only alias templates. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index cd7a581..5721007 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 0000000..faaff68 --- /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 <typename T> struct B { using f = int; }; +template <typename T, int N> struct E { + template <typename U, typename B<E>::f = 0> + void operator*(U l) { [l](T m) { m * l; }; } +}; + +int +main () +{ + E<E<float, 4>, 1> n; + n * 4.f; +} |