diff options
author | Jason Merrill <jason@redhat.com> | 2023-05-01 10:57:20 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-05-01 16:55:07 -0400 |
commit | 07c52d1eec9671af92b7ce977b469f13a87887ad (patch) | |
tree | 285dc6de4e8d715b2fb25139eff2f289a30cbf00 /gcc/cp/init.cc | |
parent | d89b152436a14cae3715af06cd52ed2d0eaafb8e (diff) | |
download | gcc-07c52d1eec9671af92b7ce977b469f13a87887ad.zip gcc-07c52d1eec9671af92b7ce977b469f13a87887ad.tar.gz gcc-07c52d1eec9671af92b7ce977b469f13a87887ad.tar.bz2 |
c++: array DMI and member fn [PR109666]
Here it turns out I also needed to adjust cfun when stepping out of the
member function to instantiate the DMI. But instead of adding that tweak,
let's unify with instantiate_body and just push_to_top_level instead of
trying to do the minimum subset of it. There was no measurable change in
compile time on stdc++.h.
This should also resolve 109506 without yet another tweak.
PR c++/109666
gcc/cp/ChangeLog:
* name-lookup.cc (maybe_push_to_top_level)
(maybe_pop_from_top_level): Split out...
* pt.cc (instantiate_body): ...from here.
* init.cc (maybe_instantiate_nsdmi_init): Use them.
* name-lookup.h: Declare them..
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/nsdmi-array2.C: New test.
Diffstat (limited to 'gcc/cp/init.cc')
-rw-r--r-- | gcc/cp/init.cc | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index 1dd24e3..0b35e10 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -597,32 +597,14 @@ maybe_instantiate_nsdmi_init (tree member, tsubst_flags_t complain) bool pushed = false; tree ctx = type_context_for_name_lookup (member); - processing_template_decl_sentinel ptds (/*reset*/false); + bool push_to_top = maybe_push_to_top_level (member); if (!currently_open_class (ctx)) { - if (!LOCAL_CLASS_P (ctx)) - push_to_top_level (); - else - /* push_to_top_level would lose the necessary function context, - just reset processing_template_decl. */ - processing_template_decl = 0; push_nested_class (ctx); push_deferring_access_checks (dk_no_deferred); pushed = true; } - /* If we didn't push_to_top_level, still step out of constructor - scope so build_base_path doesn't try to use its __in_chrg. */ - tree cfd = current_function_decl; - auto cbl = current_binding_level; - if (at_function_scope_p ()) - { - current_function_decl - = decl_function_context (current_function_decl); - while (current_binding_level->kind != sk_class) - current_binding_level = current_binding_level->level_chain; - } - inject_this_parameter (ctx, TYPE_UNQUALIFIED); start_lambda_scope (member); @@ -639,15 +621,12 @@ maybe_instantiate_nsdmi_init (tree member, tsubst_flags_t complain) if (init != error_mark_node) DECL_INITIAL (member) = init; - current_function_decl = cfd; - current_binding_level = cbl; if (pushed) { pop_deferring_access_checks (); pop_nested_class (); - if (!LOCAL_CLASS_P (ctx)) - pop_from_top_level (); } + maybe_pop_from_top_level (push_to_top); input_location = sloc; } |