Commit db60ff18 by Douglas Gregor Committed by Doug Gregor

re PR c++/33091 ([c++0x] ICE using remove_reference on variadic param pack)

2007-12-04  Douglas Gregor  <doug.gregor@gmail.com>

       PR c++/33091
       * pt.c (unify_pack_expansion): If we didn't deduce any actual
       bindings for the template parameter pack, don't try to keep the
       empty deduced arguments.
       (unify): If a parameter is a template-id whose template argument
       list contains a pack expansion that is not at the end, then we
       cannot unify against that template-id.

2007-12-04  Douglas Gregor  <doug.gregor@gmail.com>

       PR c++/33091
       * g++.dg/cpp0x/variadic-unify.C: New.

From-SVN: r130604
parent 54b7b17d
2007-12-04 Douglas Gregor <doug.gregor@gmail.com>
PR c++/33091
* pt.c (unify_pack_expansion): If we didn't deduce any actual
bindings for the template parameter pack, don't try to keep the
empty deduced arguments.
(unify): If a parameter is a template-id whose template argument
list contains a pack expansion that is not at the end, then we
cannot unify against that template-id.
2007-12-02 Paolo Carlini <pcarlini@suse.de> 2007-12-02 Paolo Carlini <pcarlini@suse.de>
PR c++/34061 PR c++/34061
......
...@@ -12464,6 +12464,16 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms, ...@@ -12464,6 +12464,16 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
{ {
tree old_pack = TREE_VALUE (pack); tree old_pack = TREE_VALUE (pack);
tree new_args = TREE_TYPE (pack); tree new_args = TREE_TYPE (pack);
int i, len = TREE_VEC_LENGTH (new_args);
bool nondeduced_p = false;
/* If NEW_ARGS contains any NULL_TREE entries, we didn't
actually deduce anything. */
for (i = 0; i < len && !nondeduced_p; ++i)
if (TREE_VEC_ELT (new_args, i) == NULL_TREE)
nondeduced_p = true;
if (nondeduced_p)
continue;
if (old_pack && ARGUMENT_PACK_INCOMPLETE_P (old_pack)) if (old_pack && ARGUMENT_PACK_INCOMPLETE_P (old_pack))
{ {
...@@ -13156,10 +13166,22 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict) ...@@ -13156,10 +13166,22 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
int argslen = TREE_VEC_LENGTH (packed_args); int argslen = TREE_VEC_LENGTH (packed_args);
int parm_variadic_p = 0; int parm_variadic_p = 0;
/* Check if the parameters end in a pack, making them variadic. */ for (i = 0; i < len; ++i)
if (len > 0 {
&& PACK_EXPANSION_P (TREE_VEC_ELT (packed_parms, len - 1))) if (PACK_EXPANSION_P (TREE_VEC_ELT (packed_parms, i)))
parm_variadic_p = 1; {
if (i == len - 1)
/* We can unify against something with a trailing
parameter pack. */
parm_variadic_p = 1;
else
/* Since there is something following the pack
expansion, we cannot unify this template argument
list. */
return 0;
}
}
/* If we don't have enough arguments to satisfy the parameters /* If we don't have enough arguments to satisfy the parameters
(not counting the pack expression at the end), or we have (not counting the pack expression at the end), or we have
......
2007-12-04 Douglas Gregor <doug.gregor@gmail.com>
PR c++/33091
* g++.dg/cpp0x/variadic-unify.C: New.
2007-12-04 Richard Guenther <rguenther@suse.de> 2007-12-04 Richard Guenther <rguenther@suse.de>
PR middle-end/34334 PR middle-end/34334
// { dg-options "-std=c++0x" }
template<typename...> struct tuple { };
template<typename... Args1, typename... Args2>
void foo(tuple<Args1..., Args2...>, tuple<Args1...>, tuple<Args2...>);
struct X{ };
void bar()
{
tuple<int, float> tif;
tuple<double, X> tdx;
tuple<int, float, double, X> tall;
foo(tall, tif, tdx);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment