This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] Use num_parm_types and nth_parm_type in match_builtin_function_types.
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 13 Jul 2006 08:46:09 -0700
- Subject: [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);