From 3f4334cb95f22e23bb2759c6c24da407f661b7b1 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 9 Apr 2017 01:38:40 -0400 Subject: [PATCH] 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. From-SVN: r246794 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 3 ++- gcc/testsuite/g++.dg/template/fn-ref1.C | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/fn-ref1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e980456918e..ee8de4c3f8a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2017-04-07 Jason Merrill + 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. + PR c++/80267 - ICE with nested capture of reference PR c++/60992 * pt.c (tsubst_copy): Handle lookup finding a capture proxy. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2d1e81fffd1..5a55f179096 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 00000000000..b2c442913a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/fn-ref1.C @@ -0,0 +1,4 @@ +// PR c++/80356 + +template struct a; +template a f(); -- 2.30.2