aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-06-24 14:47:36 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-06-24 14:47:36 -0400
commitfdfacfa112fbcd65ee32183ce54327e0ed20ef0b (patch)
tree2b4e7e69a6de444b34017c35f734a9dba0771f94
parente450b4f353ab01834cbaeae8cf31a5e0737c31ad (diff)
downloadgcc-fdfacfa112fbcd65ee32183ce54327e0ed20ef0b.zip
gcc-fdfacfa112fbcd65ee32183ce54327e0ed20ef0b.tar.gz
gcc-fdfacfa112fbcd65ee32183ce54327e0ed20ef0b.tar.bz2
pt.c (lookup_template_class): Use currently_open_class, compare template args later.
* pt.c (lookup_template_class): Use currently_open_class, compare template args later. From-SVN: r148915
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c32
2 files changed, 10 insertions, 25 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index de3828e..2a6ec5d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2009-06-24 Jason Merrill <jason@redhat.com>
+ * pt.c (lookup_template_class): Use currently_open_class,
+ compare template args later.
+
PR c++/40342
* decl.c (decls_match): Check DECL_TI_TEMPLATE too.
* class.c (resolve_address_of_overloaded_function): Fix typo.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 977a101..e0a413b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5845,31 +5845,13 @@ lookup_template_class (tree d1,
the `C<T>' is just the same as `C'. Outside of the
class, however, such a reference is an instantiation. */
- if (comp_template_args (TYPE_TI_ARGS (template_type),
- arglist))
- {
- found = template_type;
-
- if (!entering_scope && PRIMARY_TEMPLATE_P (templ))
- {
- tree ctx;
-
- for (ctx = current_class_type;
- ctx && TREE_CODE (ctx) != NAMESPACE_DECL;
- ctx = (TYPE_P (ctx)
- ? TYPE_CONTEXT (ctx)
- : DECL_CONTEXT (ctx)))
- if (TYPE_P (ctx) && same_type_p (ctx, template_type))
- goto found_ctx;
-
- /* We're not in the scope of the class, so the
- TEMPLATE_TYPE is not the type we want after all. */
- found = NULL_TREE;
- found_ctx:;
- }
- }
- if (found)
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, found);
+ if ((entering_scope
+ || !PRIMARY_TEMPLATE_P (templ)
+ || currently_open_class (template_type))
+ /* comp_template_args is expensive, check it last. */
+ && comp_template_args (TYPE_TI_ARGS (template_type),
+ arglist))
+ POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, template_type);
/* If we already have this specialization, return it. */
found = retrieve_specialization (templ, arglist,