re PR c++/58606 ([c++11] ICE with specialization in variadic template)
authorJason Merrill <jason@redhat.com>
Tue, 28 Jan 2014 04:31:14 +0000 (23:31 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 28 Jan 2014 04:31:14 +0000 (23:31 -0500)
PR c++/58606
* pt.c (template_parm_to_arg): Call convert_from_reference.
(tsubst_template_arg): Don't strip reference refs.

From-SVN: r207167

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

index 99c00a2..68fa2b9 100644 (file)
@@ -1,5 +1,9 @@
 2014-01-27  Jason Merrill  <jason@redhat.com>
 
+       PR c++/58606
+       * pt.c (template_parm_to_arg): Call convert_from_reference.
+       (tsubst_template_arg): Don't strip reference refs.
+
        PR c++/58639
        * call.c (build_aggr_conv): Reject value-initialization of reference.
 
index 4414e49..661143a 100644 (file)
@@ -3854,6 +3854,7 @@ template_parm_to_arg (tree t)
          SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
            (vec, TREE_VEC_LENGTH (vec));
 #endif
+         t = convert_from_reference (t);
          TREE_VEC_ELT (vec, 0) = make_pack_expansion (t);
 
          t  = make_node (NONTYPE_ARGUMENT_PACK);
@@ -9281,10 +9282,6 @@ tsubst_template_arg (tree t, tree args, tsubst_flags_t complain, tree in_decl)
                       /*integral_constant_expression_p=*/true);
       if (!(complain & tf_warning))
        --c_inhibit_evaluation_warnings;
-      /* Preserve the raw-reference nature of T.  */
-      if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE
-         && REFERENCE_REF_P (r))
-       r = TREE_OPERAND (r, 0);
     }
   return r;
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic146.C b/gcc/testsuite/g++.dg/cpp0x/variadic146.C
new file mode 100644 (file)
index 0000000..0c91db5
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/58606
+// { dg-require-effective-target c++11 }
+
+template<int&...I> struct A
+{
+  template<typename> struct B;
+
+  template<typename T> struct B<T*> {};
+};