| 1 |
! { dg-do run } |
| 2 |
! { dg-additional-options "-fno-inline -fno-ipa-modref -fdump-tree-optimized -fdump-tree-original" } |
| 3 |
! |
| 4 |
! PR fortran/41453 |
| 5 |
! Check that the INTENT(OUT) attribute causes one clobber to be emitted in |
| 6 |
! the caller before each call to FOO in the *.original dump, and the |
| 7 |
! initialization constants to be optimized away in the *.optimized dump, |
| 8 |
! in the case of associate variables. |
| 9 |
|
| 10 |
module x |
| 11 |
implicit none |
| 12 |
contains |
| 13 |
subroutine foo(a) |
| 14 |
integer, intent(out) :: a |
| 15 |
a = 42 |
| 16 |
end subroutine foo |
| 17 |
end module x |
| 18 |
|
| 19 |
program main |
| 20 |
use x |
| 21 |
implicit none |
| 22 |
integer :: c1, c2 |
| 23 |
|
| 24 |
c1 = 123456789 |
| 25 |
associate (d1 => c1) |
| 26 |
call foo(d1) |
| 27 |
if (d1 /= 42) stop 1 |
| 28 |
end associate |
| 29 |
if (c1 /= 42) stop 2 |
| 30 |
|
| 31 |
c2 = 0 |
| 32 |
associate (d2 => c2) |
| 33 |
d2 = 987654321 |
| 34 |
call foo(d2) |
| 35 |
if (d2 /= 42) stop 3 |
| 36 |
end associate |
| 37 |
if (c2 /= 42) stop 4 |
| 38 |
|
| 39 |
end program main |
| 40 |
|
| 41 |
! { dg-final { scan-tree-dump-times "CLOBBER" 2 "original" } } |
| 42 |
! { dg-final { scan-tree-dump "d1 = {CLOBBER};" "original" } } |
| 43 |
! { dg-final { scan-tree-dump "\\*d2 = {CLOBBER};" "original" } } |
| 44 |
! { dg-final { scan-tree-dump-not "123456789" "optimized" { target __OPTIMIZE__ } } } |
| 45 |
! { dg-final { scan-tree-dump-not "987654321" "optimized" { target __OPTIMIZE__ } } } |