diff options
author | Jason Merrill <jason@redhat.com> | 2018-02-15 13:15:32 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-02-15 13:15:32 -0500 |
commit | 4912defbcc3cc0d3a3af9673e413d45731c94da2 (patch) | |
tree | 77f7815ff9ef4bbcfd15054e7cd1262f6c2d88c0 /gcc | |
parent | 4779063140d6dc06de57d489923c91df7513f374 (diff) | |
download | gcc-4912defbcc3cc0d3a3af9673e413d45731c94da2.zip gcc-4912defbcc3cc0d3a3af9673e413d45731c94da2.tar.gz gcc-4912defbcc3cc0d3a3af9673e413d45731c94da2.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic14.C | 17 |
3 files changed, 26 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f7fd4e3..5ecc8ab 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-02-15 Jason Merrill <jason@redhat.com> + + 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 <paolo.carlini@oracle.com> PR c++/84330 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3ac7adb..cd1aed8 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 0000000..7656796 --- /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); +} |