gcc-patches@gcc.gnu.org
[Top] [All Lists]

[lto] Use alloc_parm_types in gfc_build_library_function_decl.

Subject: [lto] Use alloc_parm_types in gfc_build_library_function_decl.
From: Kazu Hirata
Date: Tue, 8 Aug 2006 21:23:56 -0700
Hi,

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

Kazu Hirata

2006-08-09  Kazu Hirata  <kazu@xxxxxxxxxxxxxxxx>

        * trans-decl.c (gfc_build_library_function_decl): Use
        alloc_parm_types.

Index: fortran/trans-decl.c
===================================================================
--- fortran/trans-decl.c        (revision 116013)
+++ fortran/trans-decl.c        (working copy)
@@ -1882,29 +1882,28 @@ tree
 gfc_build_library_function_decl (tree name, tree rettype, int nargs, ...)
 {
   tree arglist;
-  tree argtype;
   tree fntype;
   tree fndecl;
   va_list p;
-  int n;
+  int len = abs (nargs);
+  int i;
 
   /* Library functions must be declared with global scope.  */
   gcc_assert (current_function_decl == NULL_TREE);
 
-  va_start (p, nargs);
-
-
   /* Create a list of the argument types.  */
-  for (arglist = NULL_TREE, n = abs (nargs); n > 0; n--)
-    {
-      argtype = va_arg (p, tree);
-      arglist = gfc_chainon_list (arglist, argtype);
-    }
+  len = abs (nargs);
+  arglist = alloc_parm_types (len + (nargs >= 0));
+
+  va_start (p, nargs);
+  for (i = 0; i < len; i++)
+    *(nth_parm_type_ptr (arglist, i)) = va_arg (p, tree);
+  va_end (p);
 
   if (nargs >= 0)
     {
       /* Terminate the list.  */
-      arglist = gfc_chainon_list (arglist, void_type_node);
+      *(nth_parm_type_ptr (arglist, len)) = void_type_node;
     }
 
   /* Build the function type and decl.  */
@@ -1915,8 +1914,6 @@ gfc_build_library_function_decl (tree na
   DECL_EXTERNAL (fndecl) = 1;
   TREE_PUBLIC (fndecl) = 1;
 
-  va_end (p);
-
   pushdecl (fndecl);
 
   rest_of_decl_compilation (fndecl, 1, 0);

<Prev in Thread] Current Thread [Next in Thread>
  • [lto] Use alloc_parm_types in gfc_build_library_function_decl., Kazu Hirata <=