gcc/testsuite/gfortran.fortran-torture/execute/ptr.f90
raw| 1 | program ptr |
| 2 | implicit none |
| 3 | integer, pointer, dimension(:) :: a, b |
| 4 | integer, pointer :: p |
| 5 | integer, target :: i |
| 6 | |
| 7 | allocate (a(1:6)) |
| 8 | |
| 9 | a = (/ 1, 2, 3, 4, 5, 6 /) |
| 10 | b => a |
| 11 | if (any (b .ne. (/ 1, 2, 3, 4, 5, 6 /))) STOP 1 |
| 12 | b => a(1:6:2) |
| 13 | if (any (b .ne. (/ 1, 3, 5/))) STOP 2 |
| 14 | |
| 15 | p => i |
| 16 | i = 42 |
| 17 | if (p .ne. 42) STOP 3 |
| 18 | p => a(4) |
| 19 | if (p .ne. 4) STOP 4 |
| 20 | end program |