From 72a7649aa53aa210bbe0d89f1ee083f7fcfc61d6 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 7 Nov 2018 16:28:46 +0000 Subject: [PATCH] [PR C++/87904] lookup ICE https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00468.html PR c++/87904 * cp-tree.h (struct tree_overload): Fix comment. * tree.c (ovl_iterator::reveal_node): Propagate OVL_DEDUP_P. PR c++/87904 * g++.dg/lookup/pr87904.C: New. From-SVN: r265879 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-tree.h | 3 +-- gcc/cp/tree.c | 16 ++++++++++------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lookup/pr87904.C | 21 +++++++++++++++++++++ 5 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/lookup/pr87904.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b0dc668..79cc673 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-11-07 Nathan Sidwell + + PR c++/87904 + * cp-tree.h (struct tree_overload): Fix comment. + * tree.c (ovl_iterator::reveal_node): Propagate OVL_DEDUP_P. + 2018-11-04 Jason Merrill Implement UDL changes from P0732R2. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a895d00..91f5755 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -723,8 +723,7 @@ typedef struct ptrmem_cst * ptrmem_cst_t; #define OVL_SINGLE_P(NODE) \ (TREE_CODE (NODE) != OVERLOAD || !OVL_CHAIN (NODE)) -/* OVL_HIDDEN_P nodes come first, then OVL_USING_P nodes, then regular - fns. */ +/* OVL_HIDDEN_P nodes come before other nodes. */ struct GTY(()) tree_overload { struct tree_common common; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e9db3ea..5e21fce 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2261,13 +2261,17 @@ ovl_iterator::reveal_node (tree overload, tree node) OVL_HIDDEN_P (node) = false; if (tree chain = OVL_CHAIN (node)) - if (TREE_CODE (chain) == OVERLOAD - && (OVL_USING_P (chain) || OVL_HIDDEN_P (chain))) + if (TREE_CODE (chain) == OVERLOAD) { - /* The node needs moving, and the simplest way is to remove it - and reinsert. */ - overload = remove_node (overload, node); - overload = ovl_insert (OVL_FUNCTION (node), overload); + if (OVL_HIDDEN_P (chain)) + { + /* The node needs moving, and the simplest way is to remove it + and reinsert. */ + overload = remove_node (overload, node); + overload = ovl_insert (OVL_FUNCTION (node), overload); + } + else if (OVL_DEDUP_P (chain)) + OVL_DEDUP_P (node) = true; } return overload; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1975956..9bb807e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-11-07 Nathan Sidwell + + PR c++/87904 + * g++.dg/lookup/pr87904.C: New. + 2018-11-07 Uros Bizjak * gcc.dg/pr87874.c: Compile only for int128 effective target. diff --git a/gcc/testsuite/g++.dg/lookup/pr87904.C b/gcc/testsuite/g++.dg/lookup/pr87904.C new file mode 100644 index 0000000..a40b32c --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr87904.C @@ -0,0 +1,21 @@ +// PR c++ 87904 ICE failing to initiate deduping + +namespace X { + void Foo (char); +} + +struct B { + friend void Foo (int); +}; + +using X::Foo; + +void Foo (float); +void Foo(int); + +void frob () +{ + using namespace X; + + Foo (1); +} -- 2.7.4