Message ID | CADzB+2kJWcoq9bee_AOp1bNoELciw1ORun-pPaKyJ2Bjm=etsQ@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Fri, Feb 17, 2017 at 1:41 PM, Jason Merrill <jason@redhat.com> wrote: > In 79556, we try to deduce an auto type from a dependent initializer > with null TREE_TYPE, which doesn't work; fixed by catching that case > in do_auto_deduction. > > In 79549, we try to tsubst into the type of a NONTYPE_ARGUMENT_PACK, > which doesn't make sense for an auto parameter pack; in fact, it > doesn't make sense for the argument pack to have a type at all. For > GCC 7 I'm fixing this by leaving the auto type in place; for GCC 8 > we'll do away with TREE_TYPE on all NONTYPE_ARGUMENT_PACKs. And now I'm applying the GCC8 patch. Jason
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 73d6be3..093c0f9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -25191,6 +25191,10 @@ do_auto_deduction (tree type, tree init, tree auto_node, /* C++17 class template argument deduction. */ return do_class_deduction (type, tmpl, init, flags, complain); + if (TREE_TYPE (init) == NULL_TREE) + /* Nothing we can do with this, even in deduction context. */ + return type; + /* [dcl.spec.auto]: Obtain P from T by replacing the occurrences of auto with either a new invented type template parameter U or, if the initializer is a braced-init-list (8.5.4), with diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto9.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto9.C new file mode 100644 index 0000000..2daa346 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto9.C @@ -0,0 +1,8 @@ +// PR c++/79556 +// { dg-options -std=c++1z } + +template <auto> struct A; +template <auto...> struct B; +template <int N, auto Dim, auto... Dims> struct B<N, Dim, Dims...> { + static auto a = A<B<Dims...>::value>::value; +};