| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/85868 |
| 4 |
! |
| 5 |
! Contributed by Harald Anlauf <[email protected]> |
| 6 |
! |
| 7 |
|
| 8 |
program test |
| 9 |
|
| 10 |
implicit none |
| 11 |
|
| 12 |
integer, parameter :: e(*) = [1, 1, -1, -1, 0, 0, 1] |
| 13 |
|
| 14 |
integer, pointer :: t(:), u(:) |
| 15 |
integer :: i |
| 16 |
|
| 17 |
allocate (t(-1:5)) |
| 18 |
do i = -1, 5 |
| 19 |
t(i) = i |
| 20 |
end do |
| 21 |
call p (t, e(1)) ! Pointer with lower bound = -1 from allocation |
| 22 |
u => t ! Pointer assignment sets same lower bound |
| 23 |
call p (u, e(2)) |
| 24 |
! |
| 25 |
u => t(:) ! Pointer assignment with implicit lower bound (1) |
| 26 |
call p (u, e(3)) |
| 27 |
call p (t(:), e(4)) ! Full array, behaves the same |
| 28 |
! |
| 29 |
call p (t(0:), e(5)) ! Array section |
| 30 |
u => t(0:) ! Pointer assignment with implicit lower bound (1) |
| 31 |
call p (u, e(6)) |
| 32 |
u(0:) => t(0:) ! Pointer assignment with given lower bound (0) |
| 33 |
call p (u, e(7)) |
| 34 |
stop |
| 35 |
|
| 36 |
contains |
| 37 |
|
| 38 |
subroutine p (a, v) |
| 39 |
integer, pointer, intent(in) :: a(:) |
| 40 |
integer, intent(in) :: v |
| 41 |
|
| 42 |
if(a(1)/=v) stop 1001 |
| 43 |
return |
| 44 |
end subroutine p |
| 45 |
|
| 46 |
end program test |
| 47 |
|