]> gcc.gnu.org Git - gcc.git/commitdiff
c++: optimize specialization of templated member functions
authorPatrick Palka <ppalka@redhat.com>
Fri, 10 Jun 2022 20:09:58 +0000 (16:09 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 10 Jun 2022 20:09:58 +0000 (16:09 -0400)
This applies one of the lookup_template_class optimizations from the
previous patch to instantiate_template as well.

gcc/cp/ChangeLog:

* pt.cc (instantiate_template): Don't substitute the context
of the most general template if that of the partially
instantiated template is already non-dependent.

gcc/cp/pt.cc

index 079cadff37c625399403fdb4753b35482210d371..1f91fc20f7f0009f2146f071eef00acf6331cce1 100644 (file)
@@ -21714,8 +21714,14 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain)
     ++processing_template_decl;
   if (DECL_CLASS_SCOPE_P (gen_tmpl))
     {
-      tree ctx = tsubst_aggr_type (DECL_CONTEXT (gen_tmpl), targ_ptr,
-                                  complain, gen_tmpl, true);
+      tree ctx;
+      if (!uses_template_parms (DECL_CONTEXT (tmpl)))
+       /* If the context of the partially instantiated template is
+          already non-dependent, then we might as well use it.  */
+       ctx = DECL_CONTEXT (tmpl);
+      else
+       ctx = tsubst_aggr_type (DECL_CONTEXT (gen_tmpl), targ_ptr,
+                               complain, gen_tmpl, true);
       push_nested_class (ctx);
     }
 
This page took 0.114426 seconds and 5 git commands to generate.