| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-O2 -fdump-tree-original" } |
| 3 |
! |
| 4 |
! PR fortran/122977 - associate to a contiguous pointer |
| 5 |
|
| 6 |
program foo |
| 7 |
integer, dimension(:), pointer, contiguous :: a |
| 8 |
integer, dimension(:), allocatable :: u |
| 9 |
allocate (a(4), u(4)) |
| 10 |
if (.not. is_contiguous(a)) error stop 1 ! optimized |
| 11 |
if (.not. is_contiguous(u)) error stop 2 ! optimized |
| 12 |
|
| 13 |
associate (b => a) |
| 14 |
if (.not. is_contiguous(b)) error stop 3 ! optimized |
| 15 |
associate (c => b) |
| 16 |
if (.not. is_contiguous(c)) error stop 4 ! optimized |
| 17 |
end associate |
| 18 |
associate (c => b(1::2)) |
| 19 |
if (is_contiguous(c)) stop 11 ! runtime check |
| 20 |
end associate |
| 21 |
end associate |
| 22 |
|
| 23 |
associate (v => u) |
| 24 |
if (.not. is_contiguous(v)) error stop 5 ! optimized |
| 25 |
associate (w => v) |
| 26 |
if (.not. is_contiguous(w)) error stop 6 ! optimized |
| 27 |
end associate |
| 28 |
associate (w => v(1::2)) |
| 29 |
if (is_contiguous(w)) stop 12 ! runtime check |
| 30 |
end associate |
| 31 |
end associate |
| 32 |
|
| 33 |
associate (b => a(1::2)) |
| 34 |
if (is_contiguous(b)) stop 13 ! runtime check |
| 35 |
associate (c => b) |
| 36 |
if (is_contiguous(c)) stop 14 ! runtime check |
| 37 |
end associate |
| 38 |
end associate |
| 39 |
|
| 40 |
associate (v => u(1::2)) |
| 41 |
if (is_contiguous(v)) stop 15 ! runtime check |
| 42 |
associate (w => v) |
| 43 |
if (is_contiguous(w)) stop 16 ! runtime check |
| 44 |
end associate |
| 45 |
end associate |
| 46 |
|
| 47 |
deallocate (a, u) |
| 48 |
end program foo |
| 49 |
|
| 50 |
! { dg-final { scan-tree-dump-not "_gfortran_error_stop_numeric" "original" } } |
| 51 |
! { dg-final { scan-tree-dump-times "_gfortran_stop_numeric" 6 "original" } } |