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 its friends in commonparms.


Hi,

Attached is a patch to use num_parm_types and its friends in
commonparms.

Note that this patch removes the "if" statement at the beginning of
the function.  The "if" statement is responsible for making the return
value canonical by using void_list_node.  However, this is no longer
necessary because neither C or C++ frontend expects void_list_node
with one of my recent patches.

  TREE_VALUE (tree_last (TYPE_ARG_TYPES (...))) == void_type_node

is good enough.

Tested on x86_64-pc-linux-gnu.  Committed to the LTO branch as
obvious.

Kazu Hirata

2006-08-05  Kazu Hirata  <kazu@codesourcery.com>

	* typeck.c (commonparms): Use num_parm_types and its friends.

Index: cp/typeck.c
===================================================================
*** cp/typeck.c	(revision 115940)
--- cp/typeck.c	(working copy)
*************** type_unknown_p (tree exp)
*** 167,209 ****
  static tree
  commonparms (tree p1, tree p2)
  {
!   tree oldargs = p1, newargs, n;
!   int i, len;
    int any_change = 0;
  
!   len = list_length (p1);
!   newargs = tree_last (p1);
! 
!   if (newargs
!       && TREE_VALUE (newargs) == void_type_node
!       && TREE_CHAIN (newargs) == NULL_TREE)
!     i = 1;
!   else
      {
!       i = 0;
!       newargs = 0;
!     }
! 
!   for (; i < len; i++)
!     newargs = tree_cons (NULL_TREE, NULL_TREE, newargs);
! 
!   n = newargs;
  
!   for (i = 0; p1;
!        p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n), i++)
!     {
!       if (TREE_VALUE (p1) != TREE_VALUE (p2))
  	{
  	  any_change = 1;
! 	  TREE_VALUE (n) = merge_types (TREE_VALUE (p1), TREE_VALUE (p2));
  	}
        else
! 	TREE_VALUE (n) = TREE_VALUE (p1);
      }
-   if (! any_change)
-     return oldargs;
  
!   return newargs;
  }
  
  /* Given a type, perhaps copied for a typedef,
--- 167,198 ----
  static tree
  commonparms (tree p1, tree p2)
  {
!   tree new_parm_types;
    int any_change = 0;
+   int len = num_parm_types (p1);
+   int i;
  
!   new_parm_types = alloc_parm_types (len);
!   for (i = 0; i < len; i++)
      {
!       tree t1 = nth_parm_type (p1, i);
!       tree t2 = nth_parm_type (p2, i);
!       tree new_type;
  
!       if (t1 != t2)
  	{
  	  any_change = 1;
! 	  new_type = merge_types (t1, t2);
  	}
        else
! 	new_type = t1;
!       *(nth_parm_type_ptr (new_parm_types, i)) = new_type;
      }
  
!   if (!any_change)
!     return p1;
! 
!   return new_parm_types;
  }
  
  /* Given a type, perhaps copied for a typedef,


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