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-aux-info.c: Remove deserves_ellipsis.


Hi,

Attached is a patch to remove deserves_ellipsis.

I recently introduced stdarg_p in tree.c, which returns whether a
given function type was declared with an ellipsis.

It turns out that deserves_ellipsis in c-aux-info.c does the same
thing except that it looks for void_type_node in the middle of the
type list.

Since get_parm_info guarantees that void_type_node can only appear at
the end of the type list, and deserves_ellipsis is called after a
function declaration is completed, we can safely replace
deserves_ellipsis with stdarg_p.

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

Kazu Hirata

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

	* c-aux-info.c (deserves_ellipsis): Remove.
	(gen_formal_list_for_func_def): Call stdarg_p instead of
	deserves_ellipsis.

Index: c-aux-info.c
===================================================================
--- c-aux-info.c	(revision 114528)
+++ c-aux-info.c	(working copy)
@@ -43,7 +43,6 @@ static const char *data_type;
 
 static char *affix_data_type (const char *) ATTRIBUTE_MALLOC;
 static const char *gen_formal_list_for_type (tree, formals_style);
-static int   deserves_ellipsis (tree);
 static const char *gen_formal_list_for_func_def (tree, formals_style);
 static const char *gen_type (const char *, tree, formals_style);
 static const char *gen_decl (tree, int, formals_style);
@@ -184,28 +183,6 @@ gen_formal_list_for_type (tree fntype, f
   return concat (" (", formal_list, ")", NULL);
 }
 
-/* For the generation of an ANSI prototype for a function definition, we have
-   to look at the formal parameter list of the function's own "type" to
-   determine if the function's formal parameter list should end with an
-   ellipsis.  Given a tree node, the following function will return nonzero
-   if the "function type" parameter list should end with an ellipsis.  */
-
-static int
-deserves_ellipsis (tree fntype)
-{
-  tree formal_type;
-
-  formal_type = TYPE_ARG_TYPES (fntype);
-  while (formal_type && TREE_VALUE (formal_type) != void_type_node)
-    formal_type = TREE_CHAIN (formal_type);
-
-  /* If there were at least some parameters, and if the formals-types-list
-     petered out to a NULL (i.e. without being terminated by a void_type_node)
-     then we need to tack on an ellipsis.  */
-
-  return (!formal_type && TYPE_ARG_TYPES (fntype));
-}
-
 /* Generate a parameter list for a function definition (in some given style).
 
    Note that this routine has to be separate (and different) from the code that
@@ -249,7 +226,7 @@ gen_formal_list_for_func_def (tree fndec
     {
       if (!DECL_ARGUMENTS (fndecl))
 	formal_list = concat (formal_list, "void", NULL);
-      if (deserves_ellipsis (TREE_TYPE (fndecl)))
+      if (stdarg_p (TREE_TYPE (fndecl)))
 	formal_list = concat (formal_list, ", ...", NULL);
     }
   if ((style == ansi) || (style == k_and_r_names))


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