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]

Re: Require canonical type comparison for typedefs again.


On 09/20/2010 12:29 PM, Dodji Seketeli wrote:
 #define TEMPLATE_TYPE_PARM_SIBLING_PARMS(NODE) \
-  (TREE_CHECK ((NODE), TEMPLATE_TYPE_PARM))->type.maxval
+  (TREE_CHECK3 ((NODE), TEMPLATE_TYPE_PARM,    \
+		TEMPLATE_TEMPLATE_PARM,	       \
+		BOUND_TEMPLATE_TEMPLATE_PARM))->type.maxval

With your patch we aren't actually using this list anymore, only its length, so we might as well just store the length directly rather than the list. That way, this:


+      /* If T1 belongs to a not-yet fully parsed template parameters
+	 list, let's assume it's different from T2 which belongs to an
+	 already fully parsed template template parameters list.  */
+      if ((TEMPLATE_TYPE_PARM_SIBLING_PARMS
+	   (TYPE_MAIN_VARIANT (t1)) != NULL_TREE)
+	  != (TEMPLATE_TYPE_PARM_SIBLING_PARMS
+	      (TYPE_MAIN_VARIANT (t1)) != NULL_TREE))
+	return false;
+
+      /* If T1 and T2 belong to template parm lists of different
+	 size, then can't be equal.  */
+      if ((TEMPLATE_TYPE_PARM_SIBLING_PARMS
+	   (TYPE_MAIN_VARIANT (t1)) != NULL_TREE)
+	  && (TEMPLATE_TYPE_PARM_SIBLING_PARMS
+	      (TYPE_MAIN_VARIANT (t2)) != NULL_TREE)
+	  && (TREE_VEC_LENGTH (INNERMOST_TEMPLATE_PARMS
+			       (TEMPLATE_TYPE_PARM_SIBLING_PARMS
+				(TYPE_MAIN_VARIANT (t1))))
+	      != TREE_VEC_LENGTH (INNERMOST_TEMPLATE_PARMS
+				  (TEMPLATE_TYPE_PARM_SIBLING_PARMS
+				   (TYPE_MAIN_VARIANT (t2))))))
+	return false;

Can become a single simple comparison. Which should go into comp_template_parms_position.


+/* Contains canonical template parameter types. The vector is indexed
+   by the TEMPLATE_TYPE_IDX of the template parameter. Each element is
+   a TREE_LIST, whose TREE_PURPOSE is a INT_CST tree representing a
+   total size of the template parameter list a given template
+   parameter would belong too, and whose TREE_VALUEs contain the
+   canonical template parameters of various types and levels,
+   belonging to a set of template parameters which size is
+   TREE_PURPOSE.  */
 static GTY(()) VEC(tree,gc) *canonical_template_parms;

Since we're adding more elements to this table, maybe we should convert it to a hash table. But that can be a follow-on patch.


+  if (total_num_parms == 0)
+    return NULL_TREE;

Since you're already treating parms from a list of unknown length as distinct from parms from a list of known length, we can give them a canonical type, too.


+      if (TREE_CODE (parm) == TYPE_DECL
+	     || TREE_CODE (parm) == TEMPLATE_DECL)
+	{
+	  /* Compute the canonical type of type template
+	     parameters and their variants.  */

Hmm, don't we need to handle substituting type parameters into template parameters?


template <class T, template <T> class U> struct A { };

It should work to do a single loop over the template args, doing any substitution and then replacing them with their canonical variants as appropriate. Since a particular parameter can only refer to previous ones, we can't run into ordering issues.

Jason


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