| 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 scalar allocatables and pointers. |
| 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, allocatable :: ca |
| 23 |
integer, target :: ct |
| 24 |
integer, pointer :: cp |
| 25 |
|
| 26 |
allocate(ca) |
| 27 |
ca = 123456789 |
| 28 |
call foo(ca) |
| 29 |
if (ca /= 42) stop 1 |
| 30 |
deallocate(ca) |
| 31 |
|
| 32 |
ct = 987654321 |
| 33 |
cp => ct |
| 34 |
call foo(cp) |
| 35 |
if (ct /= 42) stop 2 |
| 36 |
end program main |
| 37 |
|
| 38 |
! { dg-final { scan-tree-dump-times "CLOBBER" 2 "original" } } |
| 39 |
! { dg-final { scan-tree-dump "\\*ca = {CLOBBER};" "original" } } |
| 40 |
! { dg-final { scan-tree-dump "\\*cp = {CLOBBER};" "original" } } |
| 41 |
! { dg-final { scan-tree-dump-not "123456789" "optimized" { target __OPTIMIZE__ } } } |
| 42 |
! { dg-final { scan-tree-dump-not "987654321" "optimized" { target __OPTIMIZE__ } } } |