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 <nathanieloshead@gmail.com>
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;
--- /dev/null
+// PR c++/118245
+// { dg-do compile { target c++20 } }
+
+template<auto> struct Cask {};
+struct T1 : Cask<[]{}> {
+ Cask<[]{}> c{};
+};
// { dg-additional-options "-fmodule-header -Wno-subobject-linkage" }
-// { dg-module-cmi {} }
+// { dg-ice "see PR c++/118245" { c++20 } }
#include "lambda-7.h"
// { 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"
-// { 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";