From 99be38ec6a484b92940c2d415e14db33ebfb19bc Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 3 Feb 2017 14:44:21 -0500 Subject: [PATCH] PR c++/79294 - ICE with invalid template argument * pt.c (convert_nontype_argument_function): Check value-dependence. (convert_nontype_argument): Don't check it here for function ptrs. From-SVN: r245168 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 9 +++++---- gcc/testsuite/g++.dg/template/error57.C | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/error57.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 96136af87eb..8f65db5b357 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-02-03 Jason Merrill + + PR c++/79294 - ICE with invalid template argument + * pt.c (convert_nontype_argument_function): Check value-dependence. + (convert_nontype_argument): Don't check it here for function ptrs. + 2017-02-02 Richard Biener PR cp/14179 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c69c27063e8..4c4941a88aa 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5966,6 +5966,9 @@ convert_nontype_argument_function (tree type, tree expr, if (fn == error_mark_node) return error_mark_node; + if (value_dependent_expression_p (fn)) + return fn; + fn_no_ptr = strip_fnptr_conv (fn); if (TREE_CODE (fn_no_ptr) == ADDR_EXPR) fn_no_ptr = TREE_OPERAND (fn_no_ptr, 0); @@ -6698,8 +6701,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) /* Null pointer values are OK in C++11. */ return perform_qualification_conversions (type, expr); - if (!value_dependent_expression_p (expr)) - expr = convert_nontype_argument_function (type, expr, complain); + expr = convert_nontype_argument_function (type, expr, complain); if (!expr || expr == error_mark_node) return expr; } @@ -6723,8 +6725,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) return NULL_TREE; } - if (!value_dependent_expression_p (expr)) - expr = convert_nontype_argument_function (type, expr, complain); + expr = convert_nontype_argument_function (type, expr, complain); if (!expr || expr == error_mark_node) return expr; } diff --git a/gcc/testsuite/g++.dg/template/error57.C b/gcc/testsuite/g++.dg/template/error57.C new file mode 100644 index 00000000000..f67e0a6fa63 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error57.C @@ -0,0 +1,5 @@ +// PR c++/79294 + +template struct a; +template a < b // { dg-error "int" } +// { dg-error "expected" "" { target *-*-* } .-1 } -- 2.30.2