aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-02-05 12:53:06 -0500
committerMarek Polacek <polacek@redhat.com>2020-02-06 11:58:23 -0500
commit4a136a214ede91ef05caac017814b142883dc80d (patch)
tree2fbaaf508ba18858fb6293c4f6c29204515e24da /gcc
parentf78335df69993a900512f92324cab6a20b1bde0c (diff)
downloadgcc-4a136a214ede91ef05caac017814b142883dc80d.zip
gcc-4a136a214ede91ef05caac017814b142883dc80d.tar.gz
gcc-4a136a214ede91ef05caac017814b142883dc80d.tar.bz2
c++: Fix ICE with lambda in operator function [PR93597]
If we are going to use get_first_fn let's make sure we operate on is_overloaded_fn, as the rest of the codebase does, and if lookup finds any class-scope declaration, return early too. PR c++/93597 - ICE with lambda in operator function. * name-lookup.c (maybe_save_operator_binding): Check is_overloaded_fn. * g++.dg/cpp0x/lambda/lambda-93597.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/name-lookup.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-93597.C8
4 files changed, 22 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6a7ba56..1c8af80 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-06 Marek Polacek <polacek@redhat.com>
+
+ PR c++/93597 - ICE with lambda in operator function.
+ * name-lookup.c (maybe_save_operator_binding): Check is_overloaded_fn.
+
2020-02-05 Jason Merrill <jason@redhat.com>
PR c++/93140
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 2447166..2a9bae5 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -7624,10 +7624,10 @@ 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. */
+ tree d = is_overloaded_fn (fns) ? get_first_fn (fns) : fns;
+ if (DECL_P (d) && DECL_CLASS_SCOPE_P (d))
+ /* We don't need to remember class-scope functions or declarations,
+ normal unqualified lookup will find them again. */
return;
bindings = tree_cons (fnname, fns, bindings);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d0955e0..601bc33 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-06 Marek Polacek <polacek@redhat.com>
+
+ PR c++/93597 - ICE with lambda in operator function.
+ * g++.dg/cpp0x/lambda/lambda-93597.C: New test.
+
2020-02-06 Tobias Burnus <tobias@codesourcery.com>
* gcc.target/arm/multilib.exp (multilib_config): Pass flags to
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-93597.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-93597.C
new file mode 100644
index 0000000..257d9c7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-93597.C
@@ -0,0 +1,8 @@
+// PR c++/93597 - ICE with lambda in operator function.
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+struct S {
+ using T ::operator<;
+ void operator==(T x) { [x] { 0 < x; }; }
+};