| 1 |
! { dg-do run } |
| 2 |
! { dg-additional-options "-fcheck=bounds -fdump-tree-original" } |
| 3 |
! |
| 4 |
! PR fortran/86100 - bogus bounds check with assignment, class component |
| 5 |
|
| 6 |
program p |
| 7 |
implicit none |
| 8 |
type any_matrix |
| 9 |
class(*), allocatable :: m(:,:) |
| 10 |
end type any_matrix |
| 11 |
type(any_matrix) :: a, b |
| 12 |
allocate (a%m, source=reshape([3,5],shape=[1,2])) |
| 13 |
|
| 14 |
! The following assignment did create a bogus bounds violation: |
| 15 |
b = a ! Line 15 |
| 16 |
if (any (shape (b%m) /= shape (a%m))) stop 1 |
| 17 |
|
| 18 |
contains |
| 19 |
|
| 20 |
! Verify improved array name in array name |
| 21 |
subroutine bla () |
| 22 |
type(any_matrix) :: c, d |
| 23 |
allocate (real :: c%m(3,5)) |
| 24 |
allocate (d%m(7,9),source=c%m) ! Line 24 |
| 25 |
end subroutine bla |
| 26 |
end |
| 27 |
|
| 28 |
! { dg-final { scan-tree-dump-times "around line 15.* bound mismatch for dimension 1 of array .'.*.'" 1 "original" } } |
| 29 |
! { dg-final { scan-tree-dump-times "around line 15.* bound mismatch for dimension 2 of array .'.*.'" 1 "original" } } |
| 30 |
|
| 31 |
! { dg-final { scan-tree-dump-times "At line 24 .* bound mismatch for dimension 1 of array .'d%%m.'" 1 "original" } } |
| 32 |
! { dg-final { scan-tree-dump-times "At line 24 .* bound mismatch for dimension 2 of array .'d%%m.'" 1 "original" } } |