From 82d5decef38b5562d97c49a70ca2636a08769dbc Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 1 May 2020 13:53:32 -0400 Subject: c++: Local class DMI using local static [PR90479] For default member initializers in templates it's important to push into the right context during get_nsdmi. But for a local class that's not possible, and trying leaves the function context we need to be in, so don't try. gcc/cp/ChangeLog 2020-05-01 Jason Merrill PR c++/90479 * init.c (get_nsdmi): Don't push_to_top_level for a local class. --- gcc/cp/init.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gcc/cp/init.c') diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ea95a3b..c7ae940 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -585,16 +585,18 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain) DECL_INSTANTIATING_NSDMI_P (member) = 1; bool pushed = false; - if (!currently_open_class (DECL_CONTEXT (member))) + tree ctx = DECL_CONTEXT (member); + if (!currently_open_class (ctx) + && !LOCAL_CLASS_P (ctx)) { push_to_top_level (); - push_nested_class (DECL_CONTEXT (member)); + push_nested_class (ctx); pushed = true; } gcc_checking_assert (!processing_template_decl); - inject_this_parameter (DECL_CONTEXT (member), TYPE_UNQUALIFIED); + inject_this_parameter (ctx, TYPE_UNQUALIFIED); start_lambda_scope (member); -- cgit v1.1