View | Details | Return to bug 32565
Collapse All | Expand All

(-)gcc/cp/cp/pt.c.jj (-3 / +49 lines)
Lines 12515-12521 unify (tree tparms, tree targs, tree par Link Here
12515
	    tree argvec = INNERMOST_TEMPLATE_ARGS (TYPE_TI_ARGS (arg));
12515
	    tree argvec = INNERMOST_TEMPLATE_ARGS (TYPE_TI_ARGS (arg));
12516
	    tree argtmplvec
12516
	    tree argtmplvec
12517
	      = DECL_INNERMOST_TEMPLATE_PARMS (TYPE_TI_TEMPLATE (arg));
12517
	      = DECL_INNERMOST_TEMPLATE_PARMS (TYPE_TI_TEMPLATE (arg));
12518
	    int i;
12518
	    int i, j;
12519
12519
12520
	    /* The resolution to DR150 makes clear that default
12520
	    /* The resolution to DR150 makes clear that default
12521
	       arguments for an N-argument may not be used to bind T
12521
	       arguments for an N-argument may not be used to bind T
Lines 12557-12567 unify (tree tparms, tree targs, tree par Link Here
12557
	       rather than the whole TREE_VEC since they can have
12557
	       rather than the whole TREE_VEC since they can have
12558
	       different number of elements.  */
12558
	       different number of elements.  */
12559
12559
12560
	    for (i = 0; i < TREE_VEC_LENGTH (parmvec); ++i)
12560
	    for (i = 0, j = 0; i < TREE_VEC_LENGTH (parmvec); ++i, ++j)
12561
	      {
12561
	      {
12562
		if (j >= TREE_VEC_LENGTH (argvec))
12563
		  return 1;
12564
12565
		if (ARGUMENT_PACK_P (TREE_VEC_ELT (parmvec, i))
12566
		    && !ARGUMENT_PACK_P (TREE_VEC_ELT (argvec, i)))
12567
		  {
12568
		    tree packed_parms
12569
		      = ARGUMENT_PACK_ARGS (TREE_VEC_ELT (parmvec, i));
12570
		    int len = TREE_VEC_LENGTH (packed_parms);
12571
		    int parm_variadic_p = 0;
12572
		    int argslen = TREE_VEC_LENGTH (argvec) - j;
12573
		    int k;
12574
12575
		    /* Check if the parameters end in a pack,
12576
		       making them variadic.  */
12577
		    if (len > 0 
12578
			&& PACK_EXPANSION_P (TREE_VEC_ELT (packed_parms,
12579
					     len - 1)))
12580
		      parm_variadic_p = 1;
12581
12582
		    if (parm_variadic_p && i != TREE_VEC_LENGTH (parmvec) - 1)
12583
		      return 1;
12584
12585
		    /* If we don't have enough arguments to satisfy the
12586
		       parameters, we can't unify.  */
12587
		    if (argslen < (len - parm_variadic_p))
12588
		      return 1;
12589
12590
		    /* Unify all of the parameters that precede the (optional)
12591
		       pack expression.  */
12592
		    for (k = 0; k < len - parm_variadic_p; k++)
12593
		      if (unify (tparms, targs, TREE_VEC_ELT (packed_parms, k),
12594
				 TREE_VEC_ELT (argvec, j + k),
12595
				 UNIFY_ALLOW_NONE))
12596
			return 1;
12597
12598
		    j += k - 1;
12599
12600
		    if (parm_variadic_p)
12601
		      return 1; /* FIXME */
12602
12603
		    continue;
12604
		  }
12605
12562
		if (unify (tparms, targs,
12606
		if (unify (tparms, targs,
12563
			   TREE_VEC_ELT (parmvec, i),
12607
			   TREE_VEC_ELT (parmvec, i),
12564
			   TREE_VEC_ELT (argvec, i),
12608
			   TREE_VEC_ELT (argvec, j),
12565
			   UNIFY_ALLOW_NONE))
12609
			   UNIFY_ALLOW_NONE))
12566
		  return 1;
12610
		  return 1;
12567
	      }
12611
	      }
Lines 12980-12985 unify (tree tparms, tree targs, tree par Link Here
12980
13024
12981
    case TYPE_ARGUMENT_PACK:
13025
    case TYPE_ARGUMENT_PACK:
12982
    case NONTYPE_ARGUMENT_PACK:
13026
    case NONTYPE_ARGUMENT_PACK:
13027
      if (TREE_CODE (parm) != TREE_CODE (arg))
13028
	return 1;
12983
      {
13029
      {
12984
        tree packed_parms = ARGUMENT_PACK_ARGS (parm);
13030
        tree packed_parms = ARGUMENT_PACK_ARGS (parm);
12985
        tree packed_args = ARGUMENT_PACK_ARGS (arg);
13031
        tree packed_args = ARGUMENT_PACK_ARGS (arg);
(-)gcc/cp/testsuite/g++.dg/cpp0x/variadic79.C.jj (+26 lines)
Line 0 Link Here
1
// PR c++/32565
2
// { dg-do compile }
3
// { dg-options "-std=c++0x" }
4
5
template<typename...> struct A1;
6
template<template<int...> class T> struct A1<T<0> > {};
7
template<typename...> struct A2;
8
template<template<int...> class T> struct A2<T<0, 1> > {};
9
template<typename...> struct A3;
10
template<template<int, int...> class T> struct A3<T<0, 1> > {};
11
template<typename...> struct A4;
12
template<template<typename...> class T> struct A4<T<int> > {};
13
template<typename...> struct A5;
14
template<template<typename...> class T> struct A5<T<int, long> > {};
15
template<typename...> struct A6;
16
template<template<typename, typename...> class T> struct A6<T<int, long> > {};
17
template<int> struct B1 {};
18
template<int, int> struct B2 {};
19
template<typename> struct B3 {};
20
template<typename, typename> struct B4 {};
21
A1<B1<0> > a1;
22
A2<B2<0, 1> > a2;
23
A3<B2<0, 1> > a3;
24
A4<B3<int> > a4;
25
A5<B4<int, long> > a5;
26
A6<B4<int, long> > a6;

Return to bug 32565