[Patch, Fortran, F08] PR 55207: Variables declared in the main program should implicitly get the SAVE attribute
Janne Blomqvist
blomqvist.janne@gmail.com
Mon Mar 17 13:37:00 GMT 2014
On Sun, Mar 16, 2014 at 8:40 PM, Janus Weil <janus@gcc.gnu.org> wrote:
> Index: gcc/fortran/decl.c
> ===================================================================
> --- gcc/fortran/decl.c (revision 208590)
> +++ gcc/fortran/decl.c (working copy)
> @@ -3831,7 +3831,8 @@
> implicitly have the SAVE attribute. */
> if ((gfc_current_state () == COMP_MODULE
> || gfc_current_state () == COMP_PROGRAM)
> - && !current_attr.save && (gfc_option.allow_std & GFC_STD_F2008) != 0)
> + && !current_attr.save && (gfc_option.allow_std & GFC_STD_F2008) != 0
> + && current_attr.flavor != FL_PARAMETER)
> current_attr.save = SAVE_IMPLICIT;
I'm a bit late, but does it actually make sense to check the
GFC_STD_F2008 flag instead of always doing it? AFAICS, the reasoning
behind the F2008 rule was that back in the good old days, a standard
conforming program would see no difference in behaviour whether
variables in the main program were saved (~static) or not (stack
allocated). However, with finalization procedures introduced in F2003
(?), it suddenly became possible, and thus this was a "bug" in the
standard which was closed with the F2008 rule.
That being said, the performance regression as reported by Dominique
seems to make a simple implementation of this rule a bad idea. Perhaps
only consider (non-allocatable/pointer) arrays (stack space
considerations, as mentioned by Tobi), and derived types with a
finalization procedure (is there an easy way to check for this?)?
--
Janne Blomqvist
More information about the Fortran
mailing list