[gfortran] Make all arguments to ENTRY master optional

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Tue Aug 24 15:24:00 GMT 2004


Just a little idea I had when reading some code (I'm still trying to
understand what is wrong with pointers to strings): this small patch sets the
optional attribute on arguments when merging argument lists for entry master
functions. This allows removing some special handling when generating code.

Nothing spectacular, built and tested. The line numbers in the trans-types.c
hunk are like this, because I have a few unrelated formatting fixes in my tree
which I stripped out of the diff.

- Tobi

Index: resolve.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/resolve.c,v
retrieving revision 1.13
diff -u -p -r1.13 resolve.c
--- resolve.c   23 Aug 2004 21:53:14 -0000      1.13
+++ resolve.c   24 Aug 2004 14:49:43 -0000
@@ -312,6 +312,7 @@ merge_argument_lists (gfc_symbol *proc,
       /* Add a new argument.  Argument order is not important.  */
       new_arglist = gfc_get_formal_arglist ();
       new_arglist->sym = new_sym;
+      new_arglist->sym->attr.optional = 1;
       new_arglist->next = proc->formal;
       proc->formal  = new_arglist;
     }
Index: trans-array.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-array.c,v
retrieving revision 1.19
diff -u -p -r1.19 trans-array.c
--- trans-array.c       20 Aug 2004 13:53:21 -0000      1.19
+++ trans-array.c       24 Aug 2004 15:01:13 -0000
@@ -3074,7 +3074,6 @@ gfc_trans_dummy_array_bias (gfc_symbol *
   int n;
   int checkparm;
   int no_repack;
-  bool optional_arg;

   /* Do nothing for pointer and allocatable arrays.  */
   if (sym->attr.pointer || sym->attr.allocatable)
@@ -3282,8 +3281,7 @@ gfc_trans_dummy_array_bias (gfc_symbol *

   /* Only do the entry/initialization code if the arg is present.  */
   dumdesc = GFC_DECL_SAVED_DESCRIPTOR (tmpdesc);
-  optional_arg = sym->attr.optional || sym->ns->proc_name->attr.entry_master;
-  if (optional_arg)
+  if (sym->attr.optional)
     {
       tmp = gfc_conv_expr_present (sym);
       stmt = build_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
@@ -3320,7 +3318,7 @@ gfc_trans_dummy_array_bias (gfc_symbol *
       tmp = build (NE_EXPR, boolean_type_node, tmp, tmpdesc);
       stmt = build_v (COND_EXPR, tmp, stmt, build_empty_stmt ());

-      if (optional_arg)
+      if (sym->attr.optional)
         {
           tmp = gfc_conv_expr_present (sym);
           stmt = build_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
Index: trans-types.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-types.c,v
retrieving revision 1.12
diff -u -p -r1.12 trans-types.c
--- trans-types.c       24 Aug 2004 00:30:52 -0000      1.12
+++ trans-types.c       24 Aug 2004 14:49:43 -0000
@@ -977,7 +983,7 @@ gfc_sym_type (gfc_symbol * sym)
     {
       /* We must use pointer types for potentially absent variables.  The
         optimizers assume a reference type argument is never NULL.  */
-      if (sym->attr.optional || sym->ns->proc_name->attr.entry_master)
+      if (sym->attr.optional)
        type = build_pointer_type (type);
       else
        type = build_reference_type (type);



More information about the Gcc-patches mailing list