OSDN Git Service

PR fortran/28415
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 6 Oct 2006 07:23:00 +0000 (07:23 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 6 Oct 2006 07:23:00 +0000 (07:23 +0000)
* trans-decl.c (gfc_finish_var_decl): With -fno-automatic, don't
make artificial variables or pointer to variable automatic array
TREE_STATIC.

* gfortran.dg/save_2.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117482 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/save_2.f90 [new file with mode: 0644]

index 58c1320..3015ff1 100644 (file)
@@ -1,5 +1,10 @@
 2006-10-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR fortran/28415
+       * trans-decl.c (gfc_finish_var_decl): With -fno-automatic, don't
+       make artificial variables or pointer to variable automatic array
+       TREE_STATIC.
+
        * scanner.c (skip_free_comments): Return bool instead of void.
        (gfc_next_char_literal): Don't return ' ' if & is missing after
        !$omp or !$.  Use skip_{free,fixed}_comments directly instead
index 9e50ead..f74fcd8 100644 (file)
@@ -511,7 +511,14 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
   /* Keep variables larger than max-stack-var-size off stack.  */
   if (!sym->ns->proc_name->attr.recursive
       && INTEGER_CST_P (DECL_SIZE_UNIT (decl))
-      && !gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl)))
+      && !gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl))
+        /* Put variable length auto array pointers always into stack.  */
+      && (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE
+         || sym->attr.dimension == 0
+         || sym->as->type != AS_EXPLICIT
+         || sym->attr.pointer
+         || sym->attr.allocatable)
+      && !DECL_ARTIFICIAL (decl))
     TREE_STATIC (decl) = 1;
 
   /* Handle threadprivate variables.  */
index 7fb74e7..ce15a0f 100644 (file)
@@ -1,5 +1,8 @@
 2006-10-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR fortran/28415
+       * gfortran.dg/save_2.f90: New test.
+
        PR c/29091
        * gcc.dg/pr29091.c: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/save_2.f90 b/gcc/testsuite/gfortran.dg/save_2.f90
new file mode 100644 (file)
index 0000000..87ef8ab
--- /dev/null
@@ -0,0 +1,22 @@
+! PR fortran/28415
+! { dg-do run }
+! { dg-options "-O2 -fno-automatic" }
+
+      program foo
+      integer arrlen
+      arrlen = 30
+      call bar(arrlen)
+      stop
+      end
+
+      subroutine bar(arg)
+      integer arg
+      double precision arr(arg)
+      do i = 1, arg
+         arr(i) = 1.0d0
+      enddo
+      do i = 1, arg
+         write(*,*) i, arr(i)
+      enddo
+      return
+      end