Debian Codegraph @

gcc/testsuite/gfortran.dg/intent_optimize_4.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fdump-tree-original" }
3 ! { dg-final { scan-tree-dump-times "CLOBBER" 2 "original" } }
4 !
5 ! PR fortran/106817
6 ! Check that for an actual argument whose dummy is INTENT(OUT),
7 ! the clobber that is emitted in the caller before a procedure call
8 ! happens after any expression depending on the argument value has been
9 ! evaluated.
10 !
11
12 module m
13 implicit none
14 contains
15 subroutine copy1(out, in)
16 integer, intent(in) :: in
17 integer, intent(out) :: out
18 out = in
19 end subroutine copy1
20 subroutine copy2(in, out)
21 integer, intent(in) :: in
22 integer, intent(out) :: out
23 out = in
24 end subroutine copy2
25 end module m
26
27 program p
28 use m
29 implicit none
30 integer :: a, b
31
32 ! Clobbering of a should happen after a+1 has been evaluated.
33 a = 3
34 call copy1(a, a+1)
35 if (a /= 4) stop 1
36
37 ! Clobbering order does not depend on the order of arguments.
38 ! It should also come last with reversed arguments.
39 b = 12
40 call copy2(b+1, b)
41 if (b /= 13) stop 2
42
43 end program p