diff mbox series

[C++/83287] Another overload lookup ice

Message ID c7e3320e-538e-7dce-607d-38acfd4e85fa@acm.org
State New
Headers show
Series [C++/83287] Another overload lookup ice | expand

Commit Message

Nathan Sidwell Jan. 17, 2018, 6:09 p.m. UTC
This fixes the other problem in 83287, another case where a lookup was 
not marked for keeping.  I checked other build4 (& build3) calls, and it 
looks like this is the only one where this could happen.  Also, retested 
using the original testcase and no further issues discovered.

nathan
diff mbox series

Patch

2018-01-17  Nathan Sidwell  <nathan@acm.org>

	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.

Index: cp/init.c
===================================================================
--- cp/init.c	(revision 256795)
+++ cp/init.c	(working copy)
@@ -2325,7 +2325,12 @@  build_raw_new_expr (vec<tree, va_gc> *pl
   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: testsuite/g++.dg/lookup/pr83287-2.C
===================================================================
--- testsuite/g++.dg/lookup/pr83287-2.C	(revision 0)
+++ testsuite/g++.dg/lookup/pr83287-2.C	(working copy)
@@ -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> ();
+}