[PR C++/87904] lookup ICE
authorNathan Sidwell <nathan@acm.org>
Wed, 7 Nov 2018 16:28:46 +0000 (16:28 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 7 Nov 2018 16:28:46 +0000 (16:28 +0000)
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
gcc/cp/cp-tree.h
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/pr87904.C [new file with mode: 0644]

index b0dc668..79cc673 100644 (file)
@@ -1,3 +1,9 @@
+2018-11-07  Nathan Sidwell  <nathan@acm.org>
+
+       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  <jason@redhat.com>
 
        Implement UDL changes from P0732R2.
index a895d00..91f5755 100644 (file)
@@ -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;
index e9db3ea..5e21fce 100644 (file)
@@ -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;
 }
index 1975956..9bb807e 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-07  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/87904
+       * g++.dg/lookup/pr87904.C: New.
+
 2018-11-07  Uros Bizjak  <ubizjak@gmail.com>
 
        * 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 (file)
index 0000000..a40b32c
--- /dev/null
@@ -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);
+}