https://gcc.gnu.org/g:9a16584beb312bfc493977e472dcb9d11ad5bc76

commit r14-11783-g9a16584beb312bfc493977e472dcb9d11ad5bc76
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Wed May 14 20:49:22 2025 +1000

    c++: Partially revert "Support lambdas attached to more places in modules" 
[PR118245]
    
    r14-9232-g3685fae23bb008 broke the ABI for lambdas in base classes,
    causing ICEs when different lambdas got given the same mangled name.
    
    This patch reverts the parser.cc changes from that patch to restore the
    old behaviour.  The properly fixed behaviour is available in GCC 15.1
    with r15-7202-g8990070b4297b9, but that change was not suitable for
    backporting.
    
            PR c++/118245
    
    gcc/cp/ChangeLog:
    
            * parser.cc (cp_parser_class_head): Remove lambda scope when
            parsing base classes.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/modules/lambda-7_a.H: Expect the test to fail.
            * g++.dg/modules/lambda-7_b.C: Likewise.
            * g++.dg/modules/lambda-7_c.C: Likewise.
            * g++.dg/cpp2a/lambda-uneval23.C: New test.
    
    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>

Diff:
---
 gcc/cp/parser.cc                             | 10 ++--------
 gcc/testsuite/g++.dg/cpp2a/lambda-uneval23.C |  7 +++++++
 gcc/testsuite/g++.dg/modules/lambda-7_a.H    |  2 +-
 gcc/testsuite/g++.dg/modules/lambda-7_b.C    |  1 +
 gcc/testsuite/g++.dg/modules/lambda-7_c.C    |  2 +-
 5 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index ae97ae5c5f59..4a2c1f272a3a 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -27750,16 +27750,10 @@ cp_parser_class_head (cp_parser* parser,
   if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
     {
       if (type)
-       {
-         pushclass (type);
-         start_lambda_scope (TYPE_NAME (type));
-       }
+       pushclass (type);
       bases = cp_parser_base_clause (parser);
       if (type)
-       {
-         finish_lambda_scope ();
-         popclass ();
-       }
+       popclass ();
     }
   else
     bases = NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval23.C 
b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval23.C
new file mode 100644
index 000000000000..fa009f53ff23
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval23.C
@@ -0,0 +1,7 @@
+// PR c++/118245
+// { dg-do compile { target c++20 } }
+
+template<auto> struct Cask {};
+struct T1 : Cask<[]{}> {
+  Cask<[]{}> c{};
+};
diff --git a/gcc/testsuite/g++.dg/modules/lambda-7_a.H 
b/gcc/testsuite/g++.dg/modules/lambda-7_a.H
index 5197114f76ca..842aedc5fd94 100644
--- a/gcc/testsuite/g++.dg/modules/lambda-7_a.H
+++ b/gcc/testsuite/g++.dg/modules/lambda-7_a.H
@@ -1,4 +1,4 @@
 // { dg-additional-options "-fmodule-header -Wno-subobject-linkage" }
-// { dg-module-cmi {} }
+// { dg-ice "see PR c++/118245" { c++20 } }
 
 #include "lambda-7.h"
diff --git a/gcc/testsuite/g++.dg/modules/lambda-7_b.C 
b/gcc/testsuite/g++.dg/modules/lambda-7_b.C
index 2d781e930678..cd4d0f3aa659 100644
--- a/gcc/testsuite/g++.dg/modules/lambda-7_b.C
+++ b/gcc/testsuite/g++.dg/modules/lambda-7_b.C
@@ -1,4 +1,5 @@
 // { dg-additional-options "-fmodules-ts -fno-module-lazy 
-Wno-subobject-linkage" }
+// { dg-xfail-if "see PR c++/118245" { c++20 } }
 // Test for ODR deduplication
 
 #include "lambda-7.h"
diff --git a/gcc/testsuite/g++.dg/modules/lambda-7_c.C 
b/gcc/testsuite/g++.dg/modules/lambda-7_c.C
index f283681fa96c..3fd159e08a76 100644
--- a/gcc/testsuite/g++.dg/modules/lambda-7_c.C
+++ b/gcc/testsuite/g++.dg/modules/lambda-7_c.C
@@ -1,5 +1,5 @@
-// { dg-module-do run }
 // { dg-additional-options "-fmodules-ts -fno-module-lazy 
-Wno-subobject-linkage" }
+// { dg-xfail-if "see PR c++/118245" { c++20 } }
 
 import "lambda-7_a.H";

Reply via email to