https://gcc.gnu.org/g:e5ae0a014fbc792a69267af79cfbf580566b436a

commit r14-11405-ge5ae0a014fbc792a69267af79cfbf580566b436a
Author: Marek Polacek <pola...@redhat.com>
Date:   Fri Mar 7 11:26:46 2025 -0500

    c++: ICE with lambda in fold expression in requires [PR119134]
    
    The r12-8258 fix assumes that DECL_CONTEXT of 'pack' in
    check_for_bare_parameter_packs is going to be an operator()
    but as this test shows, it can be empty.
    
            PR c++/119134
    
    gcc/cp/ChangeLog:
    
            * pt.cc (check_for_bare_parameter_packs): Check DECL_CONTEXT.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/lambda-uneval24.C: New test.
    
    Reviewed-by: Jason Merrill <ja...@redhat.com>
    (cherry picked from commit 0e47062ce70d147091f1a97ec94bd6efad92bc5e)

Diff:
---
 gcc/cp/pt.cc                                 | 1 +
 gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index d5bf6af8467f..3369e6218aa5 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -4336,6 +4336,7 @@ check_for_bare_parameter_packs (tree t, location_t loc /* 
= UNKNOWN_LOCATION */)
        tree pack = TREE_VALUE (parameter_packs);
        if (is_capture_proxy (pack)
            || (TREE_CODE (pack) == PARM_DECL
+               && DECL_CONTEXT (pack)
                && DECL_CONTEXT (DECL_CONTEXT (pack)) == lam))
          break;
       }
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C 
b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C
new file mode 100644
index 000000000000..a2b45595e479
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C
@@ -0,0 +1,4 @@
+// PR c++/119134
+// { dg-do compile { target c++20 } }
+
+void f(auto... args) requires(([args] {}, ..., true)) {}

Reply via email to