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]

[lto] Use num_parm_types and nth_parm_type in match_builtin_function_types.


Hi,

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

This function returns 0 if two parameter lists OLDARGS and NEWARGS do
not match in length.  The patch yanks the length check out of the
loop.

Tested on x86_64-pc-linux-gnu.  Committed as obvious.

Kazu Hirata

2006-07-13  Kazu Hirata  <kazu@codesourcery.com>

	* c-decl.c (match_builtin_function_types): Use num_parm_types
	and nth_parm_type.

Index: c-decl.c
===================================================================
*** c-decl.c	(revision 115307)
--- c-decl.c	(working copy)
***************
*** 995,1000 ****
--- 995,1002 ----
    tree newrettype, oldrettype;
    tree newargs, oldargs;
    tree trytype, tryargs;
+   int i;
+   int newlen, oldlen;
  
    /* Accept the return type of the new declaration if same modes.  */
    oldrettype = TREE_TYPE (oldtype);
***************
*** 1007,1024 ****
    newargs = TYPE_ARG_TYPES (newtype);
    tryargs = newargs;
  
!   while (oldargs || newargs)
      {
!       if (!oldargs
! 	  || !newargs
! 	  || !TREE_VALUE (oldargs)
! 	  || !TREE_VALUE (newargs)
! 	  || TYPE_MODE (TREE_VALUE (oldargs))
! 	     != TYPE_MODE (TREE_VALUE (newargs)))
! 	return 0;
  
!       oldargs = TREE_CHAIN (oldargs);
!       newargs = TREE_CHAIN (newargs);
      }
  
    trytype = build_function_type (newrettype, tryargs);
--- 1009,1029 ----
    newargs = TYPE_ARG_TYPES (newtype);
    tryargs = newargs;
  
!   oldlen = num_parm_types (oldargs);
!   newlen = num_parm_types (newargs);
! 
!   if (oldlen != newlen)
!     return 0;
! 
!   for (i = 0; i < oldlen; i++)
      {
!       tree oldarg = nth_parm_type (oldargs, i);
!       tree newarg = nth_parm_type (newargs, i);
  
!       if (!oldarg
! 	  || !newarg
! 	  || TYPE_MODE (oldarg) != TYPE_MODE (newarg))
! 	return 0;
      }
  
    trytype = build_function_type (newrettype, tryargs);


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