lto: Remove random_seed from section name.
[official-gcc.git] / gcc / testsuite / gfortran.dg / save_5.f90
blobbf8d59956370fb7f4b9439d08a46bf120a594cf8
1 ! { dg-do run }
2 ! { dg-options "-fno-automatic" }
4 ! PR fortran/55733
6 ! Check that -fno-automatic makes the local variable SAVEd
9 ! Scalar allocatable
10 subroutine foo(i)
11 integer :: i
12 integer, allocatable :: j
13 if (i == 1) j = 42
14 if (.not. allocated (j)) STOP 1
15 if (j /= 42) STOP 2
16 end
18 ! Deferred-length string scalar
19 subroutine bar()
20 logical, save :: first = .true.
21 character(len=:), allocatable :: str
22 if (first) then
23 first = .false.
24 if (allocated (str)) STOP 3
25 str = "ABCDEF"
26 end if
27 if (.not. allocated (str)) STOP 4
28 if (len (str) /= 6) STOP 5
29 if (str(1:6) /= "ABCDEF") STOP 6
30 end subroutine bar
32 ! Deferred-length string array
33 subroutine bar_array()
34 logical, save :: first = .true.
35 character(len=:), allocatable :: str
36 if (first) then
37 first = .false.
38 if (allocated (str)) STOP 7
39 str = "ABCDEF"
40 end if
41 if (.not. allocated (str)) STOP 8
42 if (len (str) /= 6) STOP 9
43 if (str(1:6) /= "ABCDEF") STOP 10
44 end subroutine bar_array
46 call foo(1)
47 call foo(2)
48 call bar()
49 call bar_array()
50 call bar()
51 call bar_array()
52 end