PR c++/79470 - partial ordering with reference parameters
authorJason Merrill <jason@redhat.com>
Mon, 20 Feb 2017 06:05:38 +0000 (01:05 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 20 Feb 2017 06:05:38 +0000 (01:05 -0500)
* pt.c (unify) [INDIRECT_REF]: Handle pack expansions.

From-SVN: r245589

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

index ee222b43e0ddb1e0362e3cbc72100403e2a48d47..033831d7fd01df67e29b7e37418f4941ee69bfb3 100644 (file)
@@ -1,5 +1,8 @@
 2017-02-19  Jason Merrill  <jason@redhat.com>
 
+       PR c++/79470 - partial ordering with reference parameters
+       * pt.c (unify) [INDIRECT_REF]: Handle pack expansions.
+
        PR c++/79500 - ICE with non-template deduction guide
        * pt.c (do_class_deduction): Use STRIP_TEMPLATE rather than
        DECL_TEMPLATE_RESULT.
index 46e64986491552fec4b4531a43a3bf7b5cdacb83..0a9f5d518d3f797c3ac086520900b6330ec38904 100644 (file)
@@ -20918,8 +20918,13 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
     case INDIRECT_REF:
       if (REFERENCE_REF_P (parm))
        {
+         bool pexp = PACK_EXPANSION_P (arg);
+         if (pexp)
+           arg = PACK_EXPANSION_PATTERN (arg);
          if (REFERENCE_REF_P (arg))
            arg = TREE_OPERAND (arg, 0);
+         if (pexp)
+           arg = make_pack_expansion (arg);
          return unify (tparms, targs, TREE_OPERAND (parm, 0), arg,
                        strict, explain_p);
        }
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ref1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ref1.C
new file mode 100644 (file)
index 0000000..441d386
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/79470
+// { dg-do compile { target c++11 } }
+
+    template < const int&... > struct AA;
+
+    template < > struct AA<> { };
+
+    template < const int& II, const int&... Is >
+    struct AA<II,Is...> { };
+