aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/bounds_check_25.f90
blob: c55a10217b396edd19a73c555700ce18032d1cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
! { dg-do run }
! { dg-additional-options "-fcheck=bounds -fdump-tree-original" }
!
! PR fortran/86100 - bogus bounds check with assignment, class component

program p
  implicit none
  type any_matrix
     class(*), allocatable :: m(:,:)
  end type any_matrix
  type(any_matrix) :: a, b
  allocate (a%m, source=reshape([3,5],shape=[1,2]))

  ! The following assignment did create a bogus bounds violation:
  b = a ! Line 15
  if (any (shape (b%m) /= shape (a%m))) stop 1

contains

  ! Verify improved array name in array name
  subroutine bla ()
    type(any_matrix) :: c, d
    allocate (real :: c%m(3,5))
    allocate (d%m(7,9),source=c%m) ! Line 24
  end subroutine bla
end

! { dg-final { scan-tree-dump-times "around line 15.* bound mismatch for dimension 1 of array .'.*.'" 1 "original" } }
! { dg-final { scan-tree-dump-times "around line 15.* bound mismatch for dimension 2 of array .'.*.'" 1 "original" } }

! { dg-final { scan-tree-dump-times "At line 24 .* bound mismatch for dimension 1 of array .'d%%m.'" 1 "original" } }
! { dg-final { scan-tree-dump-times "At line 24 .* bound mismatch for dimension 2 of array .'d%%m.'" 1 "original" } }