From 83484be8b822c6a7b08e15e42fac348124455713 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 16 Mar 2018 14:56:06 -0400 Subject: [PATCH] PR c++/84720 - ICE with rvalue ref non-type argument. * pt.c (invalid_nontype_parm_type_p): Prohibit rvalue reference. (convert_nontype_argument): Revert earlier change. From-SVN: r258605 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 18 +++++++----------- gcc/testsuite/g++.dg/cpp0x/rv-targ1.C | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2957ebb..fe7b32e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-03-16 Jason Merrill + PR c++/84720 - ICE with rvalue ref non-type argument. + * pt.c (invalid_nontype_parm_type_p): Prohibit rvalue reference. + (convert_nontype_argument): Revert earlier change. + PR c++/80227 - SFINAE and negative array size. * decl.c (compute_array_index_type): Use build_converted_constant_expr and valid_constant_size_p. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 32af3a4..f7b1b0d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6933,18 +6933,11 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) return NULL_TREE; } - if (!glvalue_p (expr) - || TYPE_REF_IS_RVALUE (type) != xvalue_p (expr)) + if (!lvalue_p (expr)) { if (complain & tf_error) - { - 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); - } + error ("%qE is not a valid template argument for type %qT " + "because it is not an lvalue", expr, type); return NULL_TREE; } @@ -23992,7 +23985,10 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain) { if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)) return false; - else if (POINTER_TYPE_P (type)) + else if (TYPE_PTR_P (type)) + return false; + else if (TREE_CODE (type) == REFERENCE_TYPE + && !TYPE_REF_IS_RVALUE (type)) return false; else if (TYPE_PTRMEM_P (type)) return false; diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C b/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C index b8e0dab..06516df 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv-targ1.C @@ -1,7 +1,7 @@ // PR c++/84720 // { dg-do compile { target c++11 } } -template +template // { dg-error "not a valid type" } struct a { template static void b() { -- 2.7.4