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]

Re: -fno-automatic option (PR 20592)


> I think your patch is right.  Probably noone ever investigated how this could be
> done.  Consider a complete patch pre-approved, given that the option handling
> itself will be straightforward to implement.

Commited on 4.0 and mainline after testing on i686-linux.

FX
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/ChangeLog,v
retrieving revision 1.534
diff -u -3 -p -r1.534 ChangeLog
--- ChangeLog	27 Aug 2005 11:28:51 -0000	1.534
+++ ChangeLog	31 Aug 2005 12:22:09 -0000
@@ -1,3 +1,13 @@
+2005-08-31  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+	* gfortran.h (gfc_option_t): Add flag_automatic.
+	* invoke.texi: Document the -fno-automatic option.
+	* lang.opt: Add a -fautomatic option.
+	* options.c (gfc_init_options): Default for -fautomatic is on.
+	(gfc_handle_option): Add handling of -fautomatic option.
+	* resolve.c (gfc_resolve): When -fno-automatic is used, mark
+	needed variables as SAVE.
+
 2005-08-27  Erik Edelmann  <erik.edelmann@iki.fi>
 
 	* trans-array.c (gfc_trans_deferred_array): Fix comments.
Index: gfortran.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/gfortran.h,v
retrieving revision 1.83
diff -u -3 -p -r1.83 gfortran.h
--- gfortran.h	24 Aug 2005 20:04:20 -0000	1.83
+++ gfortran.h	31 Aug 2005 12:22:09 -0000
@@ -1438,6 +1438,7 @@ typedef struct
   int flag_pack_derived;
   int flag_repack_arrays;
   int flag_f2c;
+  int flag_automatic;
   int flag_backslash;
   int flag_d_lines;
 
Index: invoke.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/invoke.texi,v
retrieving revision 1.20
diff -u -3 -p -r1.20 invoke.texi
--- invoke.texi	21 Aug 2005 15:28:23 -0000	1.20
+++ invoke.texi	31 Aug 2005 12:22:09 -0000
@@ -143,7 +143,7 @@ by type.  Explanations are in the follow
 @item Code Generation Options
 @xref{Code Gen Options,,Options for Code Generation Conventions}.
 @gccoptlist{
--ff2c -fno-underscoring  -fsecond-underscore @gol
+-fno-automatic -ff2c -fno-underscoring  -fsecond-underscore @gol
 -fbounds-check  -fmax-stack-var-size=@var{n} @gol
 -fpackderived  -frepack-arrays}
 @end table
@@ -537,8 +537,17 @@ one of the forms is listed---the one whi
 can figure out the other form by either removing @option{no-} or adding
 it.
 
-
 @table @gcctabopt
+@cindex @option{-fno-automatic} option
+@cindex options, @option{-fno-automatic}
+@item -fno-automatic
+@cindex SAVE statement
+@cindex statements, SAVE
+Treat each program unit as if the @code{SAVE} statement was specified for
+every local variable and array referenced in it. Does not affect common
+blocks. (Some Fortran compilers provide this option under the name
+@option{-static}.)
+
 @cindex @option{-ff2c} option
 @cindex options, @option{-ff2c}
 @item -ff2c
Index: lang.opt
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/lang.opt,v
retrieving revision 1.17
diff -u -3 -p -r1.17 lang.opt
--- lang.opt	21 Aug 2005 15:28:23 -0000	1.17
+++ lang.opt	31 Aug 2005 12:22:10 -0000
@@ -69,6 +69,10 @@ Wunused-labels
 F95
 Warn when a label is unused
 
+fautomatic
+F95
+Do not treat local variables and COMMON blocks as if they were named in SAVE statements
+
 fbackslash
 F95
 Specify that backslash in string introduces an escape character
Index: options.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/options.c,v
retrieving revision 1.23
diff -u -3 -p -r1.23 options.c
--- options.c	21 Aug 2005 15:28:23 -0000	1.23
+++ options.c	31 Aug 2005 12:22:10 -0000
@@ -70,6 +70,7 @@ gfc_init_options (unsigned int argc ATTR
   gfc_option.flag_no_backend = 0;
   gfc_option.flag_pack_derived = 0;
   gfc_option.flag_repack_arrays = 0;
+  gfc_option.flag_automatic = 1;
   gfc_option.flag_backslash = 1;
   gfc_option.flag_d_lines = -1;
 
@@ -329,6 +330,10 @@ gfc_handle_option (size_t scode, const c
 
     case OPT_fdollar_ok:
       gfc_option.flag_dollar_ok = value;
+      break;
+
+    case OPT_fautomatic:
+      gfc_option.flag_automatic = value;
       break;
 
     case OPT_fbackslash:
Index: resolve.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/resolve.c,v
retrieving revision 1.51
diff -u -3 -p -r1.51 resolve.c
--- resolve.c	10 Aug 2005 20:16:26 -0000	1.51
+++ resolve.c	31 Aug 2005 12:22:10 -0000
@@ -5053,7 +5053,7 @@ gfc_resolve (gfc_namespace * ns)
 
   gfc_traverse_ns (ns, resolve_values);
 
-  if (ns->save_all)
+  if (!gfc_option.flag_automatic || ns->save_all)
     gfc_save_all (ns);
 
   iter_stack = NULL;

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