OSDN Git Service

PR fortran/23677
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Sep 2005 20:06:37 +0000 (20:06 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Sep 2005 20:06:37 +0000 (20:06 +0000)
* symbol.c (gfc_is_var_automatic): Return true if character length
is non-constant rather than constant.
* resolve.c (gfc_resolve): Don't handle !gfc_option.flag_automatic
here.
* options.c (gfc_post_options): Set gfc_option.flag_max_stack_var_size
to 0 for -fno-automatic.

* gfortran.fortran-torture/execute/save_1.f90: New test.
* gfortran.dg/save_1.f90: New test.

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

gcc/fortran/ChangeLog
gcc/fortran/options.c
gcc/fortran/resolve.c
gcc/fortran/symbol.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/save_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.fortran-torture/execute/save_1.f90 [new file with mode: 0644]

index 76b0344..a376443 100644 (file)
@@ -1,3 +1,13 @@
+2005-09-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/23677
+       * symbol.c (gfc_is_var_automatic): Return true if character length
+       is non-constant rather than constant.
+       * resolve.c (gfc_resolve): Don't handle !gfc_option.flag_automatic
+       here.
+       * options.c (gfc_post_options): Set gfc_option.flag_max_stack_var_size
+       to 0 for -fno-automatic.
+
 2005-09-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/16861
index 693ac71..48df674 100644 (file)
@@ -223,6 +223,10 @@ gfc_post_options (const char **pfilename)
   if (gfc_option.flag_second_underscore == -1)
     gfc_option.flag_second_underscore = gfc_option.flag_f2c;
 
+  /* Implement -fno-automatic as -fmax-stack-var-size=0.  */
+  if (!gfc_option.flag_automatic)
+    gfc_option.flag_max_stack_var_size = 0;
+
   return false;
 }
 
index 88e7d18..a048da5 100644 (file)
@@ -5107,7 +5107,7 @@ gfc_resolve (gfc_namespace * ns)
 
   gfc_traverse_ns (ns, resolve_values);
 
-  if (!gfc_option.flag_automatic || ns->save_all)
+  if (ns->save_all)
     gfc_save_all (ns);
 
   iter_stack = NULL;
index acae453..de2de4b 100644 (file)
@@ -2345,7 +2345,7 @@ gfc_is_var_automatic (gfc_symbol * sym)
   /* Check for non-constant length character variables.  */
   if (sym->ts.type == BT_CHARACTER
       && sym->ts.cl
-      && gfc_is_constant_expr (sym->ts.cl->length))
+      && !gfc_is_constant_expr (sym->ts.cl->length))
     return true;
   return false;
 }
index 9725d20..2e060cb 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/23677
+       * gfortran.fortran-torture/execute/save_1.f90: New test.
+       * gfortran.dg/save_1.f90: New test.
+
 2005-09-26  Uros Bizjak  <uros@kss-loka.si>
 
        * gcc.target/i386/builtin-apply-mmx.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/save_1.f90 b/gcc/testsuite/gfortran.dg/save_1.f90
new file mode 100644 (file)
index 0000000..6149862
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-options "-O2 -fno-automatic" }
+      subroutine foo (b)
+       logical b
+       integer i, j
+       character*24 s
+       save i
+       if (b) then
+         i = 26
+         j = 131
+         s = 'This is a test string'
+       else
+         if (i .ne. 26 .or. j .ne. 131) call abort
+         if (s .ne. 'This is a test string') call abort
+       end if
+      end subroutine foo
+      subroutine bar (s)
+       character*42 s
+       if (s .ne. '0123456789012345678901234567890123456') call abort
+       call foo (.false.)
+      end subroutine bar
+      subroutine baz
+       character*42 s
+       ! Just clobber stack a little bit.
+       s = '0123456789012345678901234567890123456'
+       call bar (s)
+      end subroutine baz
+      call foo (.true.)
+      call baz
+      call foo (.false.)
+      end
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/save_1.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/save_1.f90
new file mode 100644 (file)
index 0000000..c838baa
--- /dev/null
@@ -0,0 +1,29 @@
+      subroutine foo (b)
+       logical b
+       integer i, j
+       character*24 s
+       save
+       if (b) then
+         i = 26
+         j = 131
+         s = 'This is a test string'
+       else
+         if (i .ne. 26 .or. j .ne. 131) call abort
+         if (s .ne. 'This is a test string') call abort
+       end if
+      end subroutine foo
+      subroutine bar (s)
+       character*42 s
+       if (s .ne. '0123456789012345678901234567890123456') call abort
+       call foo (.false.)
+      end subroutine bar
+      subroutine baz
+       character*42 s
+       ! Just clobber stack a little bit.
+       s = '0123456789012345678901234567890123456'
+       call bar (s)
+      end subroutine baz
+      call foo (.true.)
+      call baz
+      call foo (.false.)
+      end