public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8258] c++: generic lambda fn parm pack [PR104624]
@ 2022-04-26  3:54 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-04-26  3:54 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:65735d21ac410463126114c572999682f987972c

commit r12-8258-g65735d21ac410463126114c572999682f987972c
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 21 17:24:07 2022 -0400

    c++: generic lambda fn parm pack [PR104624]
    
    Parameter packs from the enclosing context can be used unexpanded in a
    lambda that is itself part of a pack expansion, but not packs that are part
    of the lambda itself.  We already check for capture packs; we also need to
    check for function parameter packs of the lambda call operator.
    
            PR c++/104624
    
    gcc/cp/ChangeLog:
    
            * pt.cc (check_for_bare_parameter_packs): Check for lambda
            function parameter pack.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp1y/lambda-generic-variadic22.C: New test.

Diff:
---
 gcc/cp/pt.cc                                           |  4 +++-
 gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic22.C | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 7dd9e6788f4..a77b3166818 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -4341,7 +4341,9 @@ check_for_bare_parameter_packs (tree t, location_t loc /* = UNKNOWN_LOCATION */)
 	 parameter_packs = TREE_CHAIN (parameter_packs))
       {
 	tree pack = TREE_VALUE (parameter_packs);
-	if (is_capture_proxy (pack))
+	if (is_capture_proxy (pack)
+	    || (TREE_CODE (pack) == PARM_DECL
+		&& DECL_CONTEXT (DECL_CONTEXT (pack)) == lam))
 	  break;
       }
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic22.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic22.C
new file mode 100644
index 00000000000..670c598a865
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic22.C
@@ -0,0 +1,15 @@
+// PR c++/104624
+// { dg-do compile { target c++14 } }
+
+template <typename T>
+auto f (T)
+{
+  auto a = [](auto ... i)	// { dg-prune-output "incomplete type" }
+  {
+    int x[][i] = { 0 };		// { dg-error "not expanded" }
+  }();
+}
+void g ()
+{
+  f(0);
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-26  3:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26  3:54 [gcc r12-8258] c++: generic lambda fn parm pack [PR104624] 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).