This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Patch for PR fortran/30432, Argument list issue


This is a patch for PR fortran/30432 which is a failure of the test
gfortran.dg/c_by_val_1.f on IA64 but which is not really a target
specific issue.

The problem is that when fortran is creating a type for a function with
no prototype it creates an arglist consisting of a single
void_type_node.  In expand_call, n_named_args is set to the list size of
type_arg_types if that pointer is not null or to the number of actual
arguments if it is null.  So expand_call obviously expects
type_arg_types to be NULL when we know nothing about the function
arguments.  But Fortran will never create a type_arg_types of NULL, it
will always put at least a void_type_node in the argument list.

On IA64 this sets n_named_args to 1 (instead of the actual number of
arguments) and causes all arguments after the first one to be treated as
unnamed arguments and this has a different argument passing convention
than named arguments and thus we loose an argument value during the
call.

This patch fixes the failure by not appending a void_type_node to the
arg list if the arg list has nothing in it.  I also had to expand an
assertion to avoid triggering it with the change.

Tested on IA64 HP-UX and Linux with no regressions.

OK to check in?

2007-01-25  Steve Ellcey  <sje@cup.hp.com>

	PR fortran/30432
	* trans-types.c (gfc_get_function_type):  Do not add void_type_node
	to empty arg list.
	* trans-decl.c (create_function_arglist): Change assert.

Index: trans-types.c
===================================================================
--- trans-types.c	(revision 121157)
+++ trans-types.c	(working copy)
@@ -1768,7 +1768,8 @@ gfc_get_function_type (gfc_symbol * sym)
   while (nstr--)
     typelist = gfc_chainon_list (typelist, gfc_charlen_type_node);
 
-  typelist = gfc_chainon_list (typelist, void_type_node);
+  if (typelist)
+    typelist = gfc_chainon_list (typelist, void_type_node);
 
   if (alternate_return)
     type = integer_type_node;
Index: trans-decl.c
===================================================================
--- trans-decl.c	(revision 121157)
+++ trans-decl.c	(working copy)
@@ -1512,7 +1512,8 @@ create_function_arglist (gfc_symbol * sy
   /* Add the hidden string length parameters.  */
   arglist = chainon (arglist, hidden_arglist);
 
-  gcc_assert (TREE_VALUE (hidden_typelist) == void_type_node);
+  gcc_assert (hidden_typelist == NULL_TREE
+              || TREE_VALUE (hidden_typelist) == void_type_node);
   DECL_ARGUMENTS (fndecl) = arglist;
 }
 


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