PR target/83368
[official-gcc.git] / gcc / testsuite / gfortran.dg / pr71883.f90
blob23ed6a680bde53e16336be1008f8815f2e4247ae
1 ! { dg-do compile }
3 ! Test the fix for pr71883, in which an ICE would follow the error.
5 ! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de>
7 program p
8 character(3), allocatable :: z(:,:)
9 z(1:2,1:2) = 'abc'
10 z(2,1) = z(12) ! { dg-error "Rank mismatch in array reference" }
11 z(21) = z(1,2) ! { dg-error "Rank mismatch in array reference" }
12 contains
13 subroutine a
14 character(3), allocatable :: z(:,:)
15 z(1:2,1:2) = 'abc'
16 z(2,1) = z(-1) ! { dg-error "Rank mismatch in array reference" }
17 z(2,1) = z(99) ! { dg-error "Rank mismatch in array reference" }
18 z(2,1) = z(huge(0)) ! { dg-error "Rank mismatch in array reference" }
19 z(2,1) = z(-huge(0)) ! { dg-error "Rank mismatch in array reference" }
20 z(-1) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
21 z(99) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
22 z(huge(0)) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
23 z(-huge(0)) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
24 end subroutine
26 subroutine b
27 character(:), allocatable :: z(:,:)
28 z(1:2,1:2) = 'abc'
29 z(2,1) = z(-1) ! { dg-error "Rank mismatch in array reference" }
30 z(2,1) = z(99) ! { dg-error "Rank mismatch in array reference" }
31 z(2,1) = z(huge(0)) ! { dg-error "Rank mismatch in array reference" }
32 z(2,1) = z(-huge(0)) ! { dg-error "Rank mismatch in array reference" }
33 z(-1) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
34 z(99) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
35 z(huge(0)) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
36 z(-huge(0)) = z(2,1) ! { dg-error "Rank mismatch in array reference" }
37 end subroutine
38 end