diff mbox series

[PR,c++/84702] ICE with default tmpl arg of overload set

Message ID 8ea07f0e-6780-c038-8024-eff34af4b81b@acm.org
State New
Headers show
Series [PR,c++/84702] ICE with default tmpl arg of overload set | expand

Commit Message

Nathan Sidwell March 5, 2018, 6:43 p.m. UTC
This fixes an ICE where we were not correctly marking a lookup as kept, 
resulting in an assertion failure later on.

nathan
diff mbox series

Patch

2018-03-05  Nathan Sidwell  <nathan@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 ();
+}