[C++/83287] Another overload lookup ice
authorNathan Sidwell <nathan@acm.org>
Wed, 17 Jan 2018 18:11:49 +0000 (18:11 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 17 Jan 2018 18:11:49 +0000 (18:11 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01580.html
PR c++/83287
* init.c (build_raw_new_expr): Scan list for lookups to keep.

PR c++/83287
* g++.dg/lookup/pr83287-2.C: New.

From-SVN: r256809

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/pr83287-2.C [new file with mode: 0644]

index 49cf0c05a5cba1d5d476d4e38a6263feb39bc5ef..71fa358f5f8cddb40d5bb2b0e4067f73fc0b025a 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-17  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/83287
+       * init.c (build_raw_new_expr): Scan list for lookups to keep.
+
 2018-01-17  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/83814
index 1be7c67d867d7224173d6dc026b62bc471aa4848..233f41c2592a760ea83f232aa463e734308f600e 100644 (file)
@@ -2325,7 +2325,12 @@ build_raw_new_expr (vec<tree, va_gc> *placement, tree type, tree nelts,
   else if (init->is_empty ())
     init_list = void_node;
   else
-    init_list = build_tree_list_vec (init);
+    {
+      init_list = build_tree_list_vec (init);
+      for (tree v = init_list; v; v = TREE_CHAIN (v))
+       if (TREE_CODE (TREE_VALUE (v)) == OVERLOAD)
+         lookup_keep (TREE_VALUE (v), true);
+    }
 
   new_expr = build4 (NEW_EXPR, build_pointer_type (type),
                     build_tree_list_vec (placement), type, nelts,
index d6c744e60de46ed0985a5f3d3601ab7becb13216..da2cc0b1cfe36c0cf4ae37f53299d2257f782e8e 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-17  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/83287
+       * g++.dg/lookup/pr83287-2.C: New.
+
 2018-01-17  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/83814
diff --git a/gcc/testsuite/g++.dg/lookup/pr83287-2.C b/gcc/testsuite/g++.dg/lookup/pr83287-2.C
new file mode 100644 (file)
index 0000000..6ea6540
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/83287 failed to keep lookup until instantiation time
+
+void foo ();
+
+namespace {
+  void foo ();
+}
+
+template <class T>
+void
+bar ()
+{
+  new T (foo); // { dg-error "cannot resolve" }
+}
+
+void
+baz ()
+{
+  bar <double> ();
+}