]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/55733 (-fno-automatic: Fails for scalar allocatables)
authorTobias Burnus <burnus@net-b.de>
Wed, 19 Dec 2012 23:05:49 +0000 (00:05 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Wed, 19 Dec 2012 23:05:49 +0000 (00:05 +0100)
2012-12-19  Tobias Burnus  <burnus@net-b.de>

        PR fortran/55733
        * trans-decl.c (gfc_create_string_length): Avoid setting
        TREE_STATIC for automatic variables with -fno-automatic.

From-SVN: r194621

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c

index 2da48f3d2ce625e1723a1ff56749dedec2248a7e..6a24ef7214ce7d945cee17e0e0c4b860a61a95c9 100644 (file)
@@ -1,3 +1,9 @@
+2012-12-19  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/55733
+       * trans-decl.c (gfc_create_string_length): Avoid setting
+       TREE_STATIC for automatic variables with -fno-automatic.
+
 2012-12-19  Tobias Burnus  <burnus@net-b.de>
            Jakub Jelinek  <jakub@redhat.com>
            Janus Weil  <janus@gcc.gnu.org>
index 3202840cb1402acbe808206aea8e4f37a6182ee4..588f55a02df27a93b033e01167bc6fbd796d3a05 100644 (file)
@@ -1089,9 +1089,15 @@ gfc_create_string_length (gfc_symbol * sym)
       tree length;
       const char *name;
 
+      /* The string length variable shall be in static memory if it is either
+        explicitly SAVED, a module variable or with -fno-automatic. Only
+        relevant is "len=:" - otherwise, it is either a constant length or
+        it is an automatic variable.  */
       bool static_length = sym->attr.save
                           || sym->ns->proc_name->attr.flavor == FL_MODULE
-                          || gfc_option.flag_max_stack_var_size == 0;
+                          || (gfc_option.flag_max_stack_var_size == 0
+                              && sym->ts.deferred && !sym->attr.dummy
+                              && !sym->attr.result && !sym->attr.function);
 
       /* Also prefix the mangled name. We need to call GFC_PREFIX for static
         variables as some systems do not support the "." in the assembler name.