1! { dg-do compile } 2! 3! Test the fix for pr71883, in which an ICE would follow the error. 4! 5! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> 6! 7program 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" } 12contains 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 25 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 38end 39