]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/84720 - ICE with rvalue ref non-type argument.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Mar 2018 18:58:15 +0000 (18:58 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Mar 2018 18:58:15 +0000 (18:58 +0000)
* pt.c (convert_nontype_argument): Handle rvalue references.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258501 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/rv-targ1.C [new file with mode: 0644]

index 6e2958bc8e9bae18b33750778a555570bf09c07a..23079f0592318c0651999abb5f981ea84d7160ab 100644 (file)
@@ -1,5 +1,8 @@
 2018-03-13  Jason Merrill  <jason@redhat.com>
 
+       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.
index fdc1c9a7a7580472a177672308b4e6b03e6e2777..a16aef6bf58eede877681a340f18f1202dec8a37 100644 (file)
@@ -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 (file)
index 0000000..b8e0dab
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/84720
+// { dg-do compile { target c++11 } }
+
+template<int &&>
+struct a {
+  template<typename...>
+  static void b() {
+    b();
+  }
+};