| 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 |
| 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 |
| 17 |
|
| 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 |
| 31 |
|
| 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 |
| 45 |
|
| 46 |
call foo(1) |
| 47 |
call foo(2) |
| 48 |
call bar() |
| 49 |
call bar_array() |
| 50 |
call bar() |
| 51 |
call bar_array() |
| 52 |
end |