aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-03-16 14:56:06 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-03-16 14:56:06 -0400
commit83484be8b822c6a7b08e15e42fac348124455713 (patch)
treecdc38c03c2d7c299dc597cfb2aabddfe9fc56858 /gcc
parent80fdaad1c73fd73b30ba10d0a67fd82a3cae52b2 (diff)
downloadgcc-83484be8b822c6a7b08e15e42fac348124455713.zip
gcc-83484be8b822c6a7b08e15e42fac348124455713.tar.gz
gcc-83484be8b822c6a7b08e15e42fac348124455713.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c18
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rv-targ1.C2
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 <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.
* 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<int &&>
+template<int &&> // { dg-error "not a valid type" }
struct a {
template<typename...>
static void b() {