]> git.ipfire.org Git - people/ms/gcc.git/blobdiff - gcc/cp/init.cc
c++: DMI in template with virtual base [PR106890]
[people/ms/gcc.git] / gcc / cp / init.cc
index 90302372340ec981a9cbd05b846e893bae7f0089..c5a55dae56393831d2a1a2bd3433361e95110ef7 100644 (file)
@@ -613,6 +613,18 @@ maybe_instantiate_nsdmi_init (tree member, tsubst_flags_t complain)
              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);
@@ -629,6 +641,8 @@ maybe_instantiate_nsdmi_init (tree member, tsubst_flags_t complain)
          if (init != error_mark_node)
            hash_map_safe_put<hm_ggc> (nsdmi_inst, member, init);
 
+         current_function_decl = cfd;
+         current_binding_level = cbl;
          if (pushed)
            {
              pop_deferring_access_checks ();