]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix mangling of lambas in static member template initializers [PR107741]
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 31 Jan 2025 10:19:45 +0000 (21:19 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Fri, 14 Feb 2025 01:14:15 +0000 (12:14 +1100)
commit12feb78be517472ca941953dce47d6e78e5a17f8
treec074f43f986550bbdf29c16fc42162786b67c093
parent397c56af99e1675fc682606b280e53feafd07be0
c++: Fix mangling of lambas in static member template initializers [PR107741]

My fix for this issue in r15-7147 turns out to not be quite sufficient;
static member templates apparently go down a different code path and
need their own handling.

PR c++/107741

gcc/cp/ChangeLog:

* cp-tree.h (is_static_data_member_initialized_in_class):
Declare new predicate.
* decl2.cc (start_initialized_static_member): Push the
TEMPLATE_DECL when appropriate.
(is_static_data_member_initialized_in_class): New predicate.
(finish_initialized_static_member): Use it.
* lambda.cc (record_lambda_scope): Likewise.
* parser.cc (cp_parser_init_declarator): Start the member decl
early for static members so that lambda scope is set.
(cp_parser_template_declaration_after_parameters): Don't
register in-class initialized static members here.

gcc/testsuite/ChangeLog:

* g++.dg/abi/lambda-ctx2-19.C: Add tests for template members.
* g++.dg/abi/lambda-ctx2-19vs20.C: Likewise.
* g++.dg/abi/lambda-ctx2-20.C: Likewise.
* g++.dg/abi/lambda-ctx2.h: Likewise.
* g++.dg/cpp0x/static-member-init-1.C: Likewise.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/cp-tree.h
gcc/cp/decl2.cc
gcc/cp/lambda.cc
gcc/cp/parser.cc
gcc/testsuite/g++.dg/abi/lambda-ctx2-19.C
gcc/testsuite/g++.dg/abi/lambda-ctx2-19vs20.C
gcc/testsuite/g++.dg/abi/lambda-ctx2-20.C
gcc/testsuite/g++.dg/abi/lambda-ctx2.h
gcc/testsuite/g++.dg/cpp0x/static-member-init-1.C