]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/55207 ([F08] Variables declared in the main program should implicitly...
authorJanus Weil <janus@gcc.gnu.org>
Sat, 15 Mar 2014 10:53:04 +0000 (11:53 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Sat, 15 Mar 2014 10:53:04 +0000 (11:53 +0100)
2014-03-15  Janus Weil  <janus@gcc.gnu.org>

PR fortran/55207
* decl.c (match_attr_spec): Variables in the main program implicitly
get the SAVE attribute in Fortran 2008.

2014-03-15  Janus Weil  <janus@gcc.gnu.org>

PR fortran/55207
* gfortran.dg/assumed_rank_7.f90: Explicitly deallocate variables.
* gfortran.dg/c_ptr_tests_16.f90: Put into subroutine.
* gfortran.dg/inline_sum_bounds_check_1.f90: Add
-Wno-aggressive-loop-optimizations and remove an unused variable.
* gfortran.dg/intent_optimize_1.f90: Put into subroutine.
* gfortran.dg/pointer_init_9.f90: New.
* gfortran.dg/volatile4.f90: Put into subroutine.
* gfortran.dg/volatile6.f90: Ditto.

From-SVN: r208590

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/assumed_rank_7.f90
gcc/testsuite/gfortran.dg/c_ptr_tests_16.f90
gcc/testsuite/gfortran.dg/inline_sum_bounds_check_1.f90
gcc/testsuite/gfortran.dg/intent_optimize_1.f90
gcc/testsuite/gfortran.dg/pointer_init_9.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/volatile4.f90
gcc/testsuite/gfortran.dg/volatile6.f90

index ba4bdf05d98dc03c294c09e4044a2bc876406b73..ce4063edd0684db1927fedd5d2a840808213f0be 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-15  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/55207
+       * decl.c (match_attr_spec): Variables in the main program implicitly
+       get the SAVE attribute in Fortran 2008.
+
 2014-03-14  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/60392
index 2d405fe983802fb829bb5b014d01d109beb0de4f..c7f5eed36824eba5673f6013d4b392a40113368d 100644 (file)
@@ -3827,9 +3827,11 @@ match_attr_spec (void)
        }
     }
 
-  /* Since Fortran 2008 module variables implicitly have the SAVE attribute.  */
-  if (gfc_current_state () == COMP_MODULE && !current_attr.save
-      && (gfc_option.allow_std & GFC_STD_F2008) != 0)
+  /* Since Fortran 2008, variables declared in a MODULE or PROGRAM
+     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 = SAVE_IMPLICIT;
 
   colon_seen = 1;
index 19557d8ad7def734bed5b21c50c16f2484a2693e..d444e4288cc4ff09e0183758b46ffefced8bb3ce 100644 (file)
@@ -1,3 +1,15 @@
+2014-03-15  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/55207
+       * gfortran.dg/assumed_rank_7.f90: Explicitly deallocate variables.
+       * gfortran.dg/c_ptr_tests_16.f90: Put into subroutine.
+       * gfortran.dg/inline_sum_bounds_check_1.f90: Add
+       -Wno-aggressive-loop-optimizations and remove an unused variable.
+       * gfortran.dg/intent_optimize_1.f90: Put into subroutine.
+       * gfortran.dg/pointer_init_9.f90: New.
+       * gfortran.dg/volatile4.f90: Put into subroutine.
+       * gfortran.dg/volatile6.f90: Ditto.
+
 2014-03-14  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/60392
index f9ff3b9aa424531d9cf6a4526fba72e751d38ff1..a5dc8157a4fef2bc8a91b092b4ad175e56ff690b 100644 (file)
@@ -24,6 +24,8 @@ call bar(ac)
 call bar(at)
 if (i /= 12) call abort()
 
+deallocate(ac,at)
+
 contains
   subroutine bar(x)
     type(t) :: x(..)
index 8855d62abaacf3af2addab912e98bf30461671a6..3602428a0ac14adfe863e4ee941992d36ff76f6a 100644 (file)
@@ -3,7 +3,7 @@
 !
 ! PR fortran/46974
 
-program test
+subroutine test
   use ISO_C_BINDING
   implicit none
   type(c_ptr) :: m
@@ -15,7 +15,7 @@ program test
      .and. int(z'41424345') /= a  &
      .and. int(z'4142434500000000',kind=8) /= a) &
     call i_do_not_exist()
-end program test
+end subroutine
 
 ! Examples contributed by Steve Kargl and James Van Buskirk
 
index 39984683d4bf23d94ab69dfb7e0b58fd6c584c07..579e936624da9cef8550c2260f4c4ea968ab2c4a 100644 (file)
@@ -1,9 +1,9 @@
 ! { dg-do run }
-! { dg-options "-fbounds-check" }
+! { dg-options "-fbounds-check -Wno-aggressive-loop-optimizations" }
 
       integer, parameter :: nx = 3, ny = 4
 
-      integer :: i, j, too_big
+      integer :: i, too_big
 
       integer, parameter, dimension(nx,ny) :: p = &
         reshape((/ (i*i, i=1,size(p)) /), shape(p))
index dbe0128d7f0d16ee5769283df8ca2f51c8c0c71c..580db4284f93e9b291d2c851bd111783c75d8db1 100644 (file)
@@ -6,7 +6,10 @@
 ! honoured.
 !
 ! PR fortran/43665
-!
+
+
+subroutine test
+
 interface
   subroutine foo(x)
     integer, intent(in) :: x
diff --git a/gcc/testsuite/gfortran.dg/pointer_init_9.f90 b/gcc/testsuite/gfortran.dg/pointer_init_9.f90
new file mode 100644 (file)
index 0000000..1b47135
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do run }
+!
+! PR 55207: [F08] Variables declared in the main program should implicitly get the SAVE attribute
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+
+  type :: c
+  end type c
+
+  type(c), target :: x
+  class(c), pointer :: px => x
+
+  if (.not. associated(px)) call abort()
+end
index f58a873dfb47accb9c45e5a8a9b25fdf3173fd0c..4ad09dcb5d7017740cbbdff3b8c3e1458b01888f 100644 (file)
@@ -2,6 +2,8 @@
 ! { dg-options "-O2 -fdump-tree-optimized" }
 ! Tests whether volatile really works
 ! PR fortran/29601
+
+subroutine sub
 logical, volatile :: t1
 logical :: t2
 integer :: i
index e42e3de3acbb1ab36b9e7b4178d533991eaadeb8..439183a1794a96dd6e4db1b73f262b84c65209bc 100644 (file)
@@ -2,6 +2,8 @@
 ! { dg-options "-O2 -fdump-tree-optimized" }
 ! Tests whether volatile really works for arrays
 ! PR fortran/29601
+
+subroutine sub
 logical, allocatable, volatile :: t1(:)
 logical, allocatable :: t2(:)
 integer :: i