[lto] Use num_parm_types and nth_parm_type in compparms.

Kazu Hirata kazu@codesourcery.com
Tue Jun 27 22:35:00 GMT 2006


Hi,

Attached is a patch to use num_parm_types and nth_parm_type in
compparms.

The patch yanks the length check out of the loop because that's
something we will easily be able to check once we start using a
TREE_VEC for TYPE_ARG_TYPES.

Tested on x86_64-pc-linux-gnu.  OK to apply to the LTO branch?

Kazu Hirata

2006-06-27  Kazu Hirata  <kazu@codesourcery.com>

	* typeck.c (compparms): Use num_parm_types and nth_parm_type
	in compparms.

Index: typeck.c
===================================================================
*** cp/typeck.c	(revision 114965)
--- cp/typeck.c	(working copy)
*************** common_base_type (tree tt1, tree tt2)
*** 1188,1215 ****
  bool
  compparms (tree parms1, int skip1, tree parms2, int skip2)
  {
!   tree t1, t2;
  
!   while (skip1--)
!     parms1 = TREE_CHAIN (parms1);
  
!   while (skip2--)
!     parms2 = TREE_CHAIN (parms2);
  
    /* An unspecified parmlist matches any specified parmlist
       whose argument types don't need default promotions.  */
  
-   for (t1 = parms1, t2 = parms2;
-        t1 || t2;
-        t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
-     {
-       /* If one parmlist is shorter than the other,
- 	 they fail to match.  */
-       if (!t1 || !t2)
- 	return false;
-       if (!same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
- 	return false;
-     }
    return true;
  }
  
--- 1188,1211 ----
  bool
  compparms (tree parms1, int skip1, tree parms2, int skip2)
  {
!   int len1 = num_parm_types (parms1);
!   int len2 = num_parm_types (parms2);
  
!   gcc_assert (skip1 <= len1);
!   gcc_assert (skip2 <= len2);
  
!   /* If one parmlist is shorter than the other, they fail to
!      match.  */
!   if (len1 - skip1 != len2 - skip2)
!     return false;
  
    /* An unspecified parmlist matches any specified parmlist
       whose argument types don't need default promotions.  */
+   for (; skip1 < len1; skip1++, skip2++)
+     if (!same_type_p (nth_parm_type (parms1, skip1),
+ 		      nth_parm_type (parms2, skip2)))
+       return false;
  
    return true;
  }
  



More information about the Gcc-patches mailing list