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
This commit is contained in:
Jason Merrill 2018-03-16 14:56:06 -04:00 committed by Jason Merrill
parent 80fdaad1c7
commit 83484be8b8
3 changed files with 12 additions and 12 deletions

View File

@ -1,5 +1,9 @@
2018-03-16 Jason Merrill <jason@redhat.com> 2018-03-16 Jason Merrill <jason@redhat.com>
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. PR c++/80227 - SFINAE and negative array size.
* decl.c (compute_array_index_type): Use * decl.c (compute_array_index_type): Use
build_converted_constant_expr and valid_constant_size_p. build_converted_constant_expr and valid_constant_size_p.

View File

@ -6933,18 +6933,11 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
return NULL_TREE; return NULL_TREE;
} }
if (!glvalue_p (expr) if (!lvalue_p (expr))
|| TYPE_REF_IS_RVALUE (type) != xvalue_p (expr))
{ {
if (complain & tf_error) if (complain & tf_error)
{ error ("%qE is not a valid template argument for type %qT "
if (TYPE_REF_IS_RVALUE (type)) "because it is not an lvalue", expr, 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; 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)) if (INTEGRAL_OR_ENUMERATION_TYPE_P (type))
return false; 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; return false;
else if (TYPE_PTRMEM_P (type)) else if (TYPE_PTRMEM_P (type))
return false; return false;

View File

@ -1,7 +1,7 @@
// PR c++/84720 // PR c++/84720
// { dg-do compile { target c++11 } } // { dg-do compile { target c++11 } }
template<int &&> template<int &&> // { dg-error "not a valid type" }
struct a { struct a {
template<typename...> template<typename...>
static void b() { static void b() {