RISC-V: Refactor Dynamic LMUL codes
[official-gcc.git] / gcc / testsuite / gfortran.dg / dtio_8.f90
blobdc0c806750578a1cc355808b77fa003c74b2a92d
1 ! { dg-do run }
3 ! Tests dtio transfer sequence types.
5 ! Note difficulty at end with comparisons at any level of optimization.
7 MODULE p
8 TYPE :: person
9 sequence
10 CHARACTER (LEN=20) :: name
11 INTEGER(4) :: age
12 END TYPE person
13 INTERFACE WRITE(UNFORMATTED)
14 MODULE PROCEDURE pwuf
15 END INTERFACE
16 INTERFACE READ(UNFORMATTED)
17 MODULE PROCEDURE pruf
18 END INTERFACE
20 CONTAINS
22 SUBROUTINE pwuf (dtv,unit,iostat,iomsg)
23 type(person), INTENT(IN) :: dtv
24 INTEGER, INTENT(IN) :: unit
25 INTEGER, INTENT(OUT) :: iostat
26 CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
27 WRITE (UNIT=UNIT) DTV%name, DTV%age
28 END SUBROUTINE pwuf
30 SUBROUTINE pruf (dtv,unit,iostat,iomsg)
31 type(person), INTENT(INOUT) :: dtv
32 INTEGER, INTENT(IN) :: unit
33 INTEGER, INTENT(OUT) :: iostat
34 CHARACTER (LEN=*), INTENT(INOUT) :: iomsg
35 READ (UNIT = UNIT) dtv%name, dtv%age
36 END SUBROUTINE pruf
38 END MODULE p
40 PROGRAM test
41 USE p
42 TYPE (person) :: chairman
43 character(10) :: line
45 chairman%name="Charlie"
46 chairman%age=62
48 OPEN (UNIT=71, status = 'scratch', FORM='UNFORMATTED')
49 write (71) chairman
50 rewind (71)
52 chairman%name = "Charles"
53 chairman%age = 0
55 read (71) chairman
56 close (unit = 71)
58 ! Straight comparisons fail at any level of optimization.
60 write(line, "(A7)") chairman%name
61 if (trim (line) .ne. "Charlie") STOP 1
62 line = " "
63 write(line, "(I4)") chairman%age
64 if (trim (line) .eq. " 62") print *, trim(line)
65 END PROGRAM test