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.
===================================================================
@@ -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,
===================================================================
@@ -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> ();
+}