My patch for 79294 to check value-dependence for function
pointer/reference template arguments was wrongly skipping the type
conversions that convert_nontype_argument_function does.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit ee2ce70b23a8217d502aa268ca1ff42d7beba660
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri Apr 7 17:54:26 2017 -0400

            PR c++/80356 - ICE with reference to function template argument.
    
            PR c++/79294
            * pt.c (convert_nontype_argument_function): Adjust type even with a
            value-dependent argument.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2d1e81f..5a55f17 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5981,7 +5981,7 @@ convert_nontype_argument_function (tree type, tree expr,
     return error_mark_node;
 
   if (value_dependent_expression_p (fn))
-    return fn;
+    goto accept;
 
   fn_no_ptr = strip_fnptr_conv (fn);
   if (TREE_CODE (fn_no_ptr) == ADDR_EXPR)
@@ -6030,6 +6030,7 @@ convert_nontype_argument_function (tree type, tree expr,
       return NULL_TREE;
     }
 
+ accept:
   if (TREE_CODE (type) == REFERENCE_TYPE)
     fn = build_address (fn);
   if (!same_type_ignoring_top_level_qualifiers_p (type, TREE_TYPE (fn)))
diff --git a/gcc/testsuite/g++.dg/template/fn-ref1.C 
b/gcc/testsuite/g++.dg/template/fn-ref1.C
new file mode 100644
index 0000000..b2c4429
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/fn-ref1.C
@@ -0,0 +1,4 @@
+// PR c++/80356
+
+template <int (&)(int, int)> struct a;
+template <int (&b)(int, int)> a<b> f();

Reply via email to