* C++ PATCH for c++/84368, wrong error with local in variadic lambda
@ 2018-02-15 18:12 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2018-02-15 18:12 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 174 bytes --]
I started adding non-pack locals to PACK_EXPANSION_EXTRA_ARGS, but was
still only looking up specializations for the packs...
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 84368.diff --]
[-- Type: text/plain, Size: 1495 bytes --]
commit c61b45ad2d0886dc53dde7ba95382efa29288b2d
Author: Jason Merrill <jason@redhat.com>
Date: Thu Feb 15 12:56:47 2018 -0500
PR c++/84368 - wrong error with local variable in variadic lambda.
* pt.c (tsubst_pack_expansion): Fix handling of non-packs in
local_specializations.
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);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-02-15 18:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 18:12 C++ PATCH for c++/84368, wrong error with local in variadic lambda Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).