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, fortran] PR 41860 -finit-local-XXX should not clobber -fno-automatic


Hi,

The problem is that -fno-automatic in the compiler means
-fmax-var-stack-size=0, implying that all local variables become
static rather than being stack allocated. However, this option does
not set the save attribute for the variable, so we miss it when doing
a default initialization. Attached patch fixes this. Regtested on
x86_64-unknown-linux-gnu, Ok for trunk?



-- 
Janne Blomqvist

Attachment: ChangeLog
Description: Binary data

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index b17e8fe..5a5fccc 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -8630,7 +8630,8 @@ apply_default_init_local (gfc_symbol *sym)
 
   /* For saved variables, we don't want to add an initializer at 
      function entry, so we just add a static initializer.  */
-  if (sym->attr.save || sym->ns->save_all)
+  if (sym->attr.save || sym->ns->save_all 
+      || gfc_option.flag_max_stack_var_size == 0)
     {
       /* Don't clobber an existing initializer!  */
       gcc_assert (sym->value == NULL);

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