Skip to content

Commit

Permalink
PR c++/85093 - too many template args with pack expansion.
Browse files Browse the repository at this point in the history
	* pt.c (coerce_template_parms): Keep pack expansion args that will
	need to be empty.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258964 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
jason committed Mar 29, 2018
1 parent 7588bde commit 9830757
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2018-03-29 Jason Merrill <[email protected]>

PR c++/85093 - too many template args with pack expansion.
* pt.c (coerce_template_parms): Keep pack expansion args that will
need to be empty.

2018-03-29 Jason Merrill <[email protected]>

* pt.c (build_non_dependent_expr): Propagate expr location.
Expand Down
16 changes: 16 additions & 0 deletions gcc/cp/pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -8497,6 +8497,22 @@ coerce_template_parms (tree parms,
goto bad_nargs;
}

if (arg_idx < nargs)
{
/* We had some pack expansion arguments that will only work if the packs
are empty, but wait until instantiation time to complain.
See variadic-ttp3.C. */
int len = nparms + (nargs - arg_idx);
tree args = make_tree_vec (len);
int i = 0;
for (; i < nparms; ++i)
TREE_VEC_ELT (args, i) = TREE_VEC_ELT (new_inner_args, i);
for (; i < len; ++i, ++arg_idx)
TREE_VEC_ELT (args, i) = TREE_VEC_ELT (inner_args,
arg_idx - pack_adjust);
new_inner_args = args;
}

if (lost)
{
gcc_assert (!(complain & tf_error) || seen_error ());
Expand Down
13 changes: 13 additions & 0 deletions gcc/testsuite/g++.dg/cpp0x/variadic-empty1.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// PR c++/85093
// { dg-do compile { target c++11 } }

template<class V> class A {};

template<class V, class... G> class B {
typedef A<V,G...> AB; // { dg-error "arguments" }
AB ab;
};

int main() {
B<int,double> b;
}

0 comments on commit 9830757

Please sign in to comment.