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