Patchwork Use void_list_node more in Fortran FE, don't make MAIN__ call varargs

login
register
mail settings
Submitter Jakub Jelinek
Date Aug. 17, 2010, 5:25 p.m.
Message ID <20100817172516.GI702@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/61944/
State New
Headers show

Comments

Jakub Jelinek - Aug. 17, 2010, 5:25 p.m.
Hi!

As discussed in the PR, this patch just makes MAIN__ call non-varargs (for
other calls more work is needed) and slightly optimizes by sharing
void_list_node by more function types.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2010-08-17  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/45304
	* trans-decl.c (build_library_function_decl_1): Chain on
	void_list_node instead of creating a new TREE_LIST.
	* trans-intrinsic.c (gfc_get_intrinsic_lib_fndecl): Likewise.
	* trans-types.c (gfc_get_function_type): Likewise.  Set
	typelist to void_list_node for the main program.


	Jakub
Tobias Burnus - Aug. 17, 2010, 5:32 p.m.
On 08/17/2010 07:25 PM, Jakub Jelinek wrote:
> As discussed in the PR, this patch just makes MAIN__ call non-varargs (for
> other calls more work is needed)

Namely, one should generate the interface based on the usage of the 
call; that way one can also give better diagnostics. (Cf. PR and PR 
linked in the PR.)

> and slightly optimizes by sharing
> void_list_node by more function types.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK. Thanks for the patch.

Tobias

> 2010-08-17  Jakub Jelinek<jakub@redhat.com>
>
> 	PR fortran/45304
> 	* trans-decl.c (build_library_function_decl_1): Chain on
> 	void_list_node instead of creating a new TREE_LIST.
> 	* trans-intrinsic.c (gfc_get_intrinsic_lib_fndecl): Likewise.
> 	* trans-types.c (gfc_get_function_type): Likewise.  Set
> 	typelist to void_list_node for the main program
Jakub Jelinek - Aug. 17, 2010, 5:37 p.m.
On Tue, Aug 17, 2010 at 07:32:26PM +0200, Tobias Burnus wrote:
>  On 08/17/2010 07:25 PM, Jakub Jelinek wrote:
> >As discussed in the PR, this patch just makes MAIN__ call non-varargs (for
> >other calls more work is needed)
> 
> Namely, one should generate the interface based on the usage of the
> call; that way one can also give better diagnostics. (Cf. PR and PR
> linked in the PR.)

That and also using void_list_node TYPE_ARG_TYPES if the procedure is known
to have zero arguments.

> >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> OK. Thanks for the patch.

Thanks.

	Jakub

Patch

--- gcc/fortran/trans-decl.c.jj	2010-08-16 19:24:22.000000000 +0200
+++ gcc/fortran/trans-decl.c	2010-08-17 10:32:38.000000000 +0200
@@ -2353,7 +2353,7 @@  build_library_function_decl_1 (tree name
   if (nargs >= 0)
     {
       /* Terminate the list.  */
-      arglist = gfc_chainon_list (arglist, void_type_node);
+      arglist = chainon (arglist, void_list_node);
     }
 
   /* Build the function type and decl.  */
--- gcc/fortran/trans-intrinsic.c.jj	2010-08-11 21:08:00.000000000 +0200
+++ gcc/fortran/trans-intrinsic.c	2010-08-17 10:33:24.000000000 +0200
@@ -684,7 +684,7 @@  gfc_get_intrinsic_lib_fndecl (gfc_intrin
       type = gfc_typenode_for_spec (&actual->expr->ts);
       argtypes = gfc_chainon_list (argtypes, type);
     }
-  argtypes = gfc_chainon_list (argtypes, void_type_node);
+  argtypes = chainon (argtypes, void_list_node);
   type = build_function_type (gfc_typenode_for_spec (ts), argtypes);
   fndecl = build_decl (input_location,
 		       FUNCTION_DECL, get_identifier (name), type);
--- gcc/fortran/trans-types.c.jj	2010-07-29 17:16:10.000000000 +0200
+++ gcc/fortran/trans-types.c	2010-08-17 10:35:24.000000000 +0200
@@ -2356,7 +2356,9 @@  gfc_get_function_type (gfc_symbol * sym)
     typelist = gfc_chainon_list (typelist, gfc_charlen_type_node);
 
   if (typelist)
-    typelist = gfc_chainon_list (typelist, void_type_node);
+    typelist = chainon (typelist, void_list_node);
+  else if (sym->attr.is_main_program)
+    typelist = void_list_node;
 
   if (alternate_return)
     type = integer_type_node;