2 ! { dg-options "-Wcharacter-truncation" }
3 ! Tests the fix for PR31266: references to CHARACTER
4 ! components lead to the wrong length being assigned to substring
9 type(data), dimension(5), target
:: y
10 character(len
=2), dimension(5) :: p
11 character(len
=3), dimension(5) :: q
13 y(:)%c
= "abcdef" ! { dg-warning "in assignment \\(5/6\\)" }
14 p(1) = y(1)%c(3:) ! { dg-warning "in assignment \\(2/3\\)" }
15 if (p(1).ne
."cd") call abort()
17 p(1) = y(1)%c
! { dg-warning "in assignment \\(2/5\\)" }
18 if (p(1).ne
."ab") call abort()
21 p
= q
! { dg-warning "CHARACTER expression will be truncated in assignment \\(2/3\\)" }
22 if (any (p
.ne
.q(:)(1:2))) call abort()