This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for a couple of minor cleanups


Some things I noticed while working on other issues:

1) The pretty-printing code was treating the injected class name for a class the same as the stub declaration, which can be confusing.

2) I've been looking at improving the performance of template lookup, and noticed that this call to comp_template_args in lookup_template_class was taking up a surprisingly large amount of time. So I moved the other conditions up, and replaced the custom code with a call to currently_open_class.

Tested x86_64-pc-linux-gnu, applied to trunk.
2009-06-24  Jason Merrill  <jason@redhat.com>

	* error.c (dump_decl): Do say "typedef" for the injected class name.

	* pt.c (lookup_template_class): Use currently_open_class,
	compare template args later.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 7be241d..98dacb1 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -862,7 +862,7 @@ dump_decl (tree t, int flags)
     {
     case TYPE_DECL:
       /* Don't say 'typedef class A' */
-      if (DECL_ARTIFICIAL (t))
+      if (DECL_ARTIFICIAL (t) && !DECL_SELF_REFERENCE_P (t))
 	{
 	  if ((flags & TFF_DECL_SPECIFIERS)
 	      && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
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,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]