Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / io04.f90
blob685e43dd6e4013bd0ed85cfd5cd20767a478e78c
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 character(kind=1,len=50) internal_file
3 character(kind=1,len=100) msg
4 character(20) sign
5 character, parameter :: const_internal_file*(*) = "(I6)"
6 integer*1 stat1, id1
7 integer*2 stat2
8 integer*4 stat4
9 integer*8 stat8
10 integer :: iunit = 10
11 integer, parameter :: junit = 11
12 integer, pointer :: a(:)
13 integer, parameter :: const_id = 66666
14 procedure(), pointer :: procptr
15 external external
16 intrinsic acos
18 namelist /nnn/ nn1, nn2
20 sign = 'suppress'
22 open(10)
24 write(*)
25 write(*, *)
26 write(*)
27 write(*, *)
28 write(unit=*) 'Ok'
29 write(unit=iunit)
30 write(unit=junit)
31 write(unit=iunit, *)
32 write(unit=junit, *)
33 write(10)
34 write(unit=10) 'Ok'
35 write(*, nnn)
36 write(10, nnn)
37 write(internal_file)
38 write(internal_file, *)
39 write(internal_file, fmt=*)
40 write(internal_file, fmt=1) 'Ok'
41 write(internal_file, nnn)
42 write(internal_file, nml=nnn)
43 write(unit=internal_file, *)
44 write(fmt=*, unit=internal_file)
45 write(10, advance='yes', fmt=1) 'Ok'
46 write(10, *, delim='quote', sign='plus') jj
47 write(10, '(A)', advance='no', asynchronous='yes', decimal='comma', &
48 err=9, id=id, iomsg=msg, iostat=stat2, round='processor_defined', &
49 sign=sign) 'Ok'
51 print*
52 print*, 'Ok'
54 allocate(a(2), stat=stat2)
55 allocate(a(8), stat=stat8)
57 !ERROR: Duplicate UNIT specifier
58 write(internal_file, unit=*)
60 !ERROR: WRITE statement must have a UNIT specifier
61 write(nml=nnn)
63 !ERROR: WRITE statement must not have a BLANK specifier
64 !ERROR: WRITE statement must not have a END specifier
65 !ERROR: WRITE statement must not have a EOR specifier
66 !ERROR: WRITE statement must not have a PAD specifier
67 write(*, eor=9, blank='zero', end=9, pad='no')
69 !ERROR: If NML appears, REC must not appear
70 !ERROR: If NML appears, FMT must not appear
71 !ERROR: If NML appears, a data list must not appear
72 write(10, nnn, rec=40, fmt=1) 'Ok'
74 !ERROR: Internal file variable 'const_internal_file' is not definable
75 !BECAUSE: '"(I6)"' is not a variable or pointer
76 write(const_internal_file, fmt=*)
78 !ERROR: If UNIT=* appears, POS must not appear
79 write(*, pos=n, nml=nnn)
81 !ERROR: If UNIT=* appears, REC must not appear
82 write(*, rec=n)
84 !ERROR: If UNIT=internal-file appears, POS must not appear
85 write(internal_file, err=9, pos=n, nml=nnn)
87 !ERROR: If UNIT=internal-file appears, REC must not appear
88 write(internal_file, rec=n, err=9)
90 !ERROR: If UNIT=* appears, REC must not appear
91 write(*, rec=13) 'Ok'
93 !ERROR: I/O unit must be a character variable or a scalar integer expression
94 write(unit, *) 'Ok'
96 !ERROR: If ADVANCE appears, UNIT=internal-file must not appear
97 write(internal_file, advance='yes', fmt=1) 'Ok'
99 !ERROR: If ADVANCE appears, an explicit format must also appear
100 write(10, advance='yes') 'Ok'
102 !ERROR: Invalid ASYNCHRONOUS value 'non'
103 write(*, asynchronous='non')
105 !ERROR: If ASYNCHRONOUS='YES' appears, UNIT=number must also appear
106 write(*, asynchronous='yes')
108 !ERROR: If ASYNCHRONOUS='YES' appears, UNIT=number must also appear
109 write(internal_file, asynchronous='yes')
111 !ERROR: If ID appears, ASYNCHRONOUS='YES' must also appear
112 write(10, *, id=id) "Ok"
114 !ERROR: If ID appears, ASYNCHRONOUS='YES' must also appear
115 write(10, *, id=id, asynchronous='no') "Ok"
117 !ERROR: If POS appears, REC must not appear
118 write(10, pos=13, rec=13) 'Ok'
120 !ERROR: If DECIMAL appears, FMT or NML must also appear
121 !ERROR: If ROUND appears, FMT or NML must also appear
122 !ERROR: If SIGN appears, FMT or NML must also appear
123 !ERROR: Invalid DECIMAL value 'Komma'
124 write(10, decimal='Komma', sign='plus', round='down') jj
126 !ERROR: If DELIM appears, FMT=* or NML must also appear
127 !ERROR: Invalid DELIM value 'Nix'
128 write(delim='Nix', fmt='(A)', unit=10) 'Ok'
130 !ERROR: ID kind (1) is smaller than default INTEGER kind (4)
131 write(id=id1, unit=10, asynchronous='Yes') 'Ok'
133 !ERROR: ID variable 'const_id' is not definable
134 !BECAUSE: '66666_4' is not a variable or pointer
135 write(10, *, asynchronous='yes', id=const_id, iostat=stat2) 'Ok'
137 write(*, '(X)')
139 !ERROR: Output item must not be a procedure
140 print*, procptr
141 !ERROR: Output item must not be a procedure
142 print*, acos
143 !ERROR: Output item must not be a procedure
144 print*, external
146 1 format (A)
147 9 continue