PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / dec_static_1.f90
blobfc2b907e63ad4cf0165c911288ae99358bab50f4
1 ! { dg-do run }
2 ! { dg-options "-fdec-static -finit-local-zero" }
4 ! Test AUTOMATIC and STATIC attributes.
6 subroutine assert(s, i1, i2)
7 implicit none
8 integer, intent(in) :: i1, i2
9 character(*), intent(in) :: s
10 if (i1 .ne. i2) then
11 print *, s, ": expected ", i2, " but was ", i1
12 STOP 1
13 endif
14 endsubroutine assert
16 function f (x, y)
17 implicit none
18 integer f
19 integer, intent(in) :: x, y
20 integer :: a ! only a can actually be saved
21 integer, automatic :: c ! should actually be automatic
22 save
24 ! a should be incremented by x every time and saved
25 a = a + x
26 f = a
28 ! c should be zeroed every time, therefore equal y
29 c = c + y
30 call assert ("f%c", c, y)
31 return
32 endfunction
34 implicit none
35 integer :: f
37 ! Should return static value of a; accumulates x
38 call assert ("f()", f(1,3), 1)
39 call assert ("f()", f(1,4), 2)
40 call assert ("f()", f(1,2), 3)
42 end