From f71c1a187b70b88d90263b209ea402fc38d4ec92 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 13 Mar 2018 14:58:15 -0400 Subject: [PATCH] PR c++/84720 - ICE with rvalue ref non-type argument. * pt.c (convert_nontype_argument): Handle rvalue references. From-SVN: r258501 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 13 ++++++++++--- gcc/testsuite/g++.dg/cpp0x/rv-targ1.C | 10 ++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/rv-targ1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6e2958bc8e9..23079f05923 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2018-03-13 Jason Merrill + PR c++/84720 - ICE with rvalue ref non-type argument. + * pt.c (convert_nontype_argument): Handle rvalue references. + PR c++/84839 - ICE with decltype of parameter pack. * pt.c (tsubst_pack_expansion): Set cp_unevaluated_operand while instantiating dummy parms. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fdc1c9a7a75..a16aef6bf58 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6932,11 +6932,18 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) return NULL_TREE; } - if (!lvalue_p (expr)) + if (!glvalue_p (expr) + || TYPE_REF_IS_RVALUE (type) != xvalue_p (expr)) { if (complain & tf_error) - error ("%qE is not a valid template argument for type %qT " - "because it is not an lvalue", expr, type); + { + if (TYPE_REF_IS_RVALUE (type)) + error ("%qE is not a valid template argument for type %qT " + "because it is not an xvalue", expr, type); + else + error ("%qE is not a valid template argument for type %qT " + "because it is not an lvalue", expr, type); + } return NULL_TREE; } diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C b/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C new file mode 100644 index 00000000000..b8e0daba0f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C @@ -0,0 +1,10 @@ +// PR c++/84720 +// { dg-do compile { target c++11 } } + +template +struct a { + template + static void b() { + b(); + } +}; -- 2.30.2