C++ PATCH for c++/79470, partial ordering with reference parameters

Jason Merrill jason@redhat.com
Mon Feb 20 05:56:00 GMT 2017


We have code in unify to handle the implicit indirection through a
reference, but it couldn't handle when that indirection was wrapped in
an EXPR_PACK_EXPANSION.

Tested x86_64-pc-linux-gnu, applying to trunk.
-------------- next part --------------
commit 75e6ade977ea2d229d5ccd4fdaaf812c634c4d41
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Feb 19 14:28:39 2017 -0800

            PR c++/79470 - partial ordering with reference parameters
    
            * pt.c (unify) [INDIRECT_REF]: Handle pack expansions.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 46e6498..0a9f5d5 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 0000000..441d386
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ref1.C
@@ -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...> { };
+


More information about the Gcc-patches mailing list