[PR c++/84702] ICE with default tmpl arg of overload set
authorNathan Sidwell <nathan@acm.org>
Mon, 5 Mar 2018 18:44:24 +0000 (18:44 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 5 Mar 2018 18:44:24 +0000 (18:44 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00227.html
PR c++/84702
* pt.c (process_template_arg): Mark lookup_keep on a default arg.

PR c++/84702
* g++.dg/lookup/pr84702.C: New.

From-SVN: r258258

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/pr84702.C [new file with mode: 0644]

index 001cb6a559ae8dc7bcad9dd1774ae6b90d8bf905..3218814124eafecb8cad987a24a142651f0580f1 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-05  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84702
+       * pt.c (process_template_arg): Mark lookup_keep on a default arg.
+
 2018-03-05  Marek Polacek  <polacek@redhat.com>
 
        PR c++/84707
index c81bd5094d95dd693a74bb8ddacb8bec8b2df6f6..89024c10fe2ba5aa8e618c78bd987575072ff3c8 100644 (file)
@@ -4425,6 +4425,9 @@ process_template_parm (tree list, location_t parm_loc, tree parm,
 
   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 e80a72802eeda6a7f6bdfd9acb42ca8c1b8988e8..9f9afb0df1290c0ab5d85c180135008465a266f8 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-05  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84702
+       * g++.dg/lookup/pr84702.C: New.
+
 2018-03-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/84564
diff --git a/gcc/testsuite/g++.dg/lookup/pr84702.C b/gcc/testsuite/g++.dg/lookup/pr84702.C
new file mode 100644 (file)
index 0000000..6b9e1b4
--- /dev/null
@@ -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 ();
+}