| 1 |
! { dg-do compile } |
| 2 |
! { dg-additional-options "-Wextra" } |
| 3 |
! |
| 4 |
! Ensure that contiguous pointers pointing to noncontiguous pointers |
| 5 |
! to array results in a warning with -Wextra. |
| 6 |
|
| 7 |
program cont_01_neg |
| 8 |
implicit none |
| 9 |
real, pointer, contiguous :: r(:) |
| 10 |
real, pointer, contiguous :: r2(:,:) |
| 11 |
real, target, allocatable :: x(:) |
| 12 |
real, target, allocatable :: x2(:,:) |
| 13 |
real, target :: y(45) |
| 14 |
real, target :: y2(5,9) |
| 15 |
integer :: i |
| 16 |
integer :: n=1 |
| 17 |
|
| 18 |
x = (/ (real(i),i=1,45) /) |
| 19 |
x2 = reshape(x,shape(x2)) |
| 20 |
y = x |
| 21 |
y2 = x2 |
| 22 |
|
| 23 |
r => x(::3) ! { dg-warning "ssignment to contiguous pointer from non-contiguous target" } |
| 24 |
r2 => x2(2:,:) ! { dg-warning "ssignment to contiguous pointer from non-contiguous target" } |
| 25 |
r2 => x2(:,2:3) |
| 26 |
r => x2(2:3,1) |
| 27 |
r => x(::1) |
| 28 |
r => x(::n) ! { dg-warning "ssignment to contiguous pointer from non-contiguous target" } |
| 29 |
|
| 30 |
r => y(::3) ! { dg-error "ssignment to contiguous pointer from non-contiguous target" } |
| 31 |
r2 => y2(2:,:) ! { dg-error "ssignment to contiguous pointer from non-contiguous target" } |
| 32 |
r2 => y2(:,2:3) |
| 33 |
r => y2(2:3,1) |
| 34 |
r => y(::1) |
| 35 |
r => y(::n) ! { dg-warning "ssignment to contiguous pointer from non-contiguous target" } |
| 36 |
end program |