Debian Codegraph @

gcc/testsuite/gfortran.dg/pr68155.f90

raw
1 ! { dg-do run }
2 !
3 ! Fix for PR68155 in which initializers of constant length, character
4 ! components of derived types were not being padded if they were too short.
5 ! Originally, mismatched lengths caused ICEs. This seems to have been fixed
6 ! in 9-branch.
7 !
8 ! Contributed by Gerhard Steinmetz <[email protected]>
9 !
10 program p
11 implicit none
12 type t
13 character(3) :: c1(2) = [ 'b', 'c'] ! OK
14 character(3) :: c2(2) = [ character(1) :: 'b', 'c'] // "" ! OK
15 character(3) :: c3(2) = [ 'b', 'c'] // "" ! was not padded
16 character(3) :: c4(2) = [ '' , '' ] // "" ! was not padded
17 character(3) :: c5(2) = [ 'b', 'c'] // 'a' ! was not padded
18 character(3) :: c6(2) = [ 'b', 'c'] // 'ax' ! OK
19 character(3) :: c7(2) = [ 'b', 'c'] // 'axy' ! OK trimmed
20 end type t
21 type(t) :: z
22 if (z%c1(2) .ne. 'c ') stop 1
23 if (z%c2(2) .ne. 'c ') stop 2
24 if (z%c3(2) .ne. 'c ') stop 3
25 if (z%c4(2) .ne. ' ') stop 4
26 if (z%c5(2) .ne. 'ca ') stop 5
27 if (z%c6(2) .ne. 'cax') stop 6
28 if (z%c7(2) .ne. 'cax') stop 7
29 end