PR c++/84720 - ICE with rvalue ref non-type argument.
authorJason Merrill <jason@redhat.com>
Fri, 16 Mar 2018 18:56:06 +0000 (14:56 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 16 Mar 2018 18:56:06 +0000 (14:56 -0400)
* pt.c (invalid_nontype_parm_type_p): Prohibit rvalue reference.
(convert_nontype_argument): Revert earlier change.

From-SVN: r258605

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/rv-targ1.C

index 2957ebb..fe7b32e 100644 (file)
@@ -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.
index 32af3a4..f7b1b0d 100644 (file)
@@ -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;
index b8e0dab..06516df 100644 (file)
@@ -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() {