This fixes an ICE where we were not correctly marking a lookup as kept,
resulting in an assertion failure later on.
nathan
--
Nathan Sidwell
2018-03-05 Nathan Sidwell <nat...@acm.org>
PR c++/84702
* pt.c (process_template_arg): Mark lookup_keep on a default arg.
PR c++/84702
* g++.dg/lookup/pr84702.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 258254)
+++ cp/pt.c (working copy)
@@ -4425,6 +4425,9 @@ process_template_parm (tree list, locati
pushdecl (decl);
+ if (defval && TREE_CODE (defval) == OVERLOAD)
+ lookup_keep (defval, true);
+
/* Build the parameter node linking the parameter declaration,
its default argument (if any), and its constraints (if any). */
parm = build_tree_list (defval, parm);
Index: testsuite/g++.dg/lookup/pr84702.C
===================================================================
--- testsuite/g++.dg/lookup/pr84702.C (revision 0)
+++ testsuite/g++.dg/lookup/pr84702.C (working copy)
@@ -0,0 +1,13 @@
+// PR c++/84702 failure to mark overload to keep
+// { dg-do compile { target c++11 } }
+
+void a ();
+
+namespace {
+ void a (int);
+}
+
+template<void (&b)() = a>
+void c () {
+ c ();
+}