2 ! { dg-options "-fdec-static -fno-automatic -finit-local-zero" }
4 ! Test STATIC and AUTOMATIC with -fno-automatic and recursive subroutines.
6 subroutine assert(s
, i1
, i2
)
8 integer, intent(in
) :: i1
, i2
9 character(*), intent(in
) :: s
11 print *, s
, ": expected ", i2
, " but was ", i1
19 integer, intent(in
) :: x
20 integer, static :: a
! should be SAVEd
21 a
= a
+ x
! should increment by x every time
26 recursive subroutine g (x
)
28 integer, intent(in
) :: x
29 integer, automatic :: a
! should be automatic (in recursive)
30 a
= a
+ x
! should be set to x every time
31 call assert ("g%a", a
, x
)
36 integer, intent(in
) :: x
37 integer, automatic :: a
! should be automatic (outside recursive)
38 a
= a
+ x
! should be set to x every time
39 call assert ("h%a", a
, x
)
45 ! Should return static value of c; accumulates x
46 call assert ("f()", f(3), 3)
47 call assert ("f()", f(4), 7)
48 call assert ("f()", f(2), 9)