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