aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-06-10 16:09:58 -0400
committerPatrick Palka <ppalka@redhat.com>2022-06-10 16:09:58 -0400
commitf9b5a8e58dfd0642bea932d449ad46da9e57396f (patch)
tree49669abea358ff708234ce2b3a6389a05c83d6d4
parentcb7fd1ea85feea7ef65328330fc2577a95e99400 (diff)
downloadgcc-f9b5a8e58dfd0642bea932d449ad46da9e57396f.zip
gcc-f9b5a8e58dfd0642bea932d449ad46da9e57396f.tar.gz
gcc-f9b5a8e58dfd0642bea932d449ad46da9e57396f.tar.bz2
c++: optimize specialization of templated member functions
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.
-rw-r--r--gcc/cp/pt.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 079cadf..1f91fc2 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -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);
}