diff options
author | Jason Merrill <jason@redhat.com> | 2018-03-29 15:38:41 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-03-29 15:38:41 -0400 |
commit | 1e2b90c4ac0b08279fdfe65c6fab3c49573f236c (patch) | |
tree | ed8fe08cf27a9873c80884ca7486e3ebbf1f733e /gcc | |
parent | 8de4a6749d16ac2663ee5a071906b8d469ad9049 (diff) | |
download | gcc-1e2b90c4ac0b08279fdfe65c6fab3c49573f236c.zip gcc-1e2b90c4ac0b08279fdfe65c6fab3c49573f236c.tar.gz gcc-1e2b90c4ac0b08279fdfe65c6fab3c49573f236c.tar.bz2 |
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.
From-SVN: r258964
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/variadic-empty1.C | 13 |
3 files changed, 35 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cc950e8..1536c35 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2018-03-29 Jason Merrill <jason@redhat.com> + 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 <jason@redhat.com> + * pt.c (build_non_dependent_expr): Propagate expr location. 2018-03-27 Jason Merrill <jason@redhat.com> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 40ddf9e..284eaf3 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 ()); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-empty1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-empty1.C new file mode 100644 index 0000000..42daeaa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-empty1.C @@ -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; +} |