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] c-format.c: Simplify handle_format_attribute using list_length.


Hi,

Attached is a patch to simplify handle_format_attribute using
list_length.

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

Kazu Hirata

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

	* c-format.c (handle_format_attribute): Simplify using
	list_length.

Index: c-format.c
===================================================================
*** c-format.c	(revision 114548)
--- c-format.c	(working copy)
***************
*** 2713,2735 ****
        if (!check_format_string (argument, info.format_num, flags,
  				no_add_attrs))
  	return NULL_TREE;
! 
!       if (info.first_arg_num != 0)
  	{
! 	  unsigned HOST_WIDE_INT arg_num = 1;
! 
! 	  /* Verify that first_arg_num points to the last arg,
! 	     the ...  */
! 	  while (argument)
! 	    arg_num++, argument = TREE_CHAIN (argument);
! 
! 	  if (arg_num != info.first_arg_num)
! 	    {
! 	      if (!(flags & (int) ATTR_FLAG_BUILT_IN))
! 		error ("args to be formatted is not %<...%>");
! 	      *no_add_attrs = true;
! 	      return NULL_TREE;
! 	    }
  	}
      }
  
--- 2713,2728 ----
        if (!check_format_string (argument, info.format_num, flags,
  				no_add_attrs))
  	return NULL_TREE;
!       
!       /* Verify that first_arg_num points to the last arg, the ...  */
!       if (info.first_arg_num != 0
! 	  && (1 + (unsigned HOST_WIDE_INT) list_length (argument)
! 	      != info.first_arg_num))
  	{
! 	  if (!(flags & (int) ATTR_FLAG_BUILT_IN))
! 	    error ("args to be formatted is not %<...%>");
! 	  *no_add_attrs = true;
! 	  return NULL_TREE;
  	}
      }
  


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