Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gfortran.dg/dec_static_1.f90 @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line source
! { dg-do run } ! { dg-options "-fdec-static -finit-local-zero" } ! ! Test AUTOMATIC and STATIC attributes. ! subroutine assert(s, i1, i2) implicit none integer, intent(in) :: i1, i2 character(*), intent(in) :: s if (i1 .ne. i2) then print *, s, ": expected ", i2, " but was ", i1 STOP 1 endif endsubroutine assert function f (x, y) implicit none integer f integer, intent(in) :: x, y integer :: a ! only a can actually be saved integer, automatic :: c ! should actually be automatic save ! a should be incremented by x every time and saved a = a + x f = a ! c should be zeroed every time, therefore equal y c = c + y call assert ("f%c", c, y) return endfunction implicit none integer :: f ! Should return static value of a; accumulates x call assert ("f()", f(1,3), 1) call assert ("f()", f(1,4), 2) call assert ("f()", f(1,2), 3) end