From: Jason Merrill Date: Thu, 15 Feb 2018 18:15:32 +0000 (-0500) Subject: PR c++/84368 - wrong error with local variable in variadic lambda. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4912defbcc3cc0d3a3af9673e413d45731c94da2;p=gcc.git PR c++/84368 - wrong error with local variable in variadic lambda. * pt.c (tsubst_pack_expansion): Fix handling of non-packs in local_specializations. From-SVN: r257699 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f7fd4e36278..5ecc8ab2672 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-02-15 Jason Merrill + + PR c++/84368 - wrong error with local variable in variadic lambda. + * pt.c (tsubst_pack_expansion): Fix handling of non-packs in + local_specializations. + 2018-02-15 Paolo Carlini PR c++/84330 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3ac7adba00c..cd1aed8d677 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11521,8 +11521,9 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, context. */ tree gen = TREE_PURPOSE (elt); tree inst = TREE_VALUE (elt); - if (DECL_PACK_P (inst)) - inst = retrieve_local_specialization (inst); + if (DECL_P (inst)) + if (tree local = retrieve_local_specialization (inst)) + inst = local; /* else inst is already a full instantiation of the pack. */ register_local_specialization (inst, gen); } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic14.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic14.C new file mode 100644 index 00000000000..76567966293 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic14.C @@ -0,0 +1,17 @@ +// PR c++/84368 +// { dg-do compile { target c++14 } } + +template < typename ... T > +void sink(T ...){} + +template < typename ... T > +void foo(T ... v){ + [](auto ... v){ + auto bar = [](auto, auto){ return 0; }; + sink(bar(v, T{}) ...); + }(v ...); +} + +int main(){ + foo(0); +}