1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 character(len
=20) :: access
= "direcT"
3 character(len
=20) :: access_(2) = (/"direcT", "streaM"/)
4 character(len
=20) :: action_(2) = (/"reaD ", "writE"/)
5 character(len
=20) :: asynchronous_(2) = (/"nO ", "yeS"/)
6 character(len
=20) :: blank_(2) = (/"nulL", "zerO"/)
7 character(len
=20) :: decimal_(2) = (/'commA', 'poinT'/)
8 character(len
=20) :: delim_(2) = (/"nonE ", "quotE"/)
9 character(len
=20) :: encoding_(2) = (/"defaulT", "utF-8 "/)
10 character(len
=20) :: form_(2) = (/"formatteD ", "unformatteD"/)
11 character(len
=20) :: pad_(2) = (/"nO ", "yeS"/)
12 character(len
=20) :: position_(3) = (/"appenD", "asiS ", "rewinD"/)
13 character(len
=20) :: round_(2) = (/"dowN", "zerO"/)
14 character(len
=20) :: sign_(2) = (/"pluS ", "suppresS"/)
15 character(len
=20) :: status_(2) = (/"neW", "olD"/)
16 character(len
=20) :: convert_(2) = (/"big_endiaN", "nativE "/)
17 character(len
=20) :: dispose_(2) = (/ "deletE", "keeP "/)
18 character(len
=66) :: cc
, msg
21 integer :: unit10
= 10
22 integer :: unit11
= 11
24 integer, parameter :: const_new_unit
= 66
26 integer(kind
=1) :: stat1
27 integer(kind
=2) :: stat2
28 integer(kind
=4) :: stat4
29 integer(kind
=8) :: stat8
34 open(blank
='null', unit
=unit10
, pad
='no')
35 open(unit
=unit11
, err
=3)
38 open(20, access
='sequential')
39 open(21, access
=access
, recl
=n
)
40 open(22, access
=access_(2), iostat
=stat1
, iomsg
=msg
)
42 open(30, action
='readwrite', asynchronous
='n'//'o', blank
='zero')
43 open(31, action
=action_(2), asynchronous
=asynchronous_(2), blank
=blank_(2))
45 open(unit
=40, decimal
="comma", delim
="apostrophe", encoding
="utf-8")
46 open(unit
=41, decimal
=decimal_(2), delim
=delim_(2), encoding
=encoding_(2))
48 open(50, file
='abc', status
='unknown', form
='formatted')
49 open(51, file
=access
, status
=status_(2), form
=form_(2))
51 open(newunit
=new_unit
, pad
=pad_(2), status
='scr'//'atch'//'')
52 open(newunit
=new_unit
, pad
=pad_(2), status
=cc
)
54 open(unit
=60, position
='rewind', recl
=(30+20/2), round
='zero')
55 open(position
=position_(1), recl
=n
, round
=round_(2), unit
=61)
57 open(unit
=70, sign
='suppress', &
58 status
='unknown', iostat
=stat2
)
59 open(unit
=70, sign
=sign_(2), status
=status_(2))
61 open(80, convert
='big_endian', dispose
='delete')
62 open(81, convert
=convert_(2), dispose
=dispose_(2))
64 open(access
='STREAM', 90) ! nonstandard
65 open (unit
=91, file
='xfile', carriagecontrol
='list') ! nonstandard
67 !ERROR: OPEN statement must have a UNIT or NEWUNIT specifier
68 !ERROR: If ACCESS='DIRECT' appears, RECL must also appear
71 !ERROR: If STATUS='STREAM' appears, RECL must not appear
72 open(10, access
='st'//'ream', recl
=13)
74 !ERROR: Duplicate NEWUNIT specifier
75 !ERROR: If NEWUNIT appears, FILE or STATUS must also appear
76 open(newunit
=n
, newunit
=nn
, iostat
=stat4
)
78 !ERROR: NEWUNIT variable 'const_new_unit' is not definable
79 !BECAUSE: '66_4' is not a variable or pointer
80 open(newunit
=const_new_unit
, status
=cc
)
82 !ERROR: Duplicate UNIT specifier
83 open(unit
=100, unit
=100)
85 !ERROR: Duplicate UNIT specifier
86 open(101, delim
=delim_(1), unit
=102)
88 !ERROR: Duplicate UNIT specifier
90 unit
=104, iostat
=stat8
)
92 !ERROR: Duplicate UNIT specifier
93 !ERROR: If ACCESS='DIRECT' appears, RECL must also appear
94 open(access
='dir'//'ect', 9, 9) ! nonstandard
96 !ERROR: Duplicate ROUND specifier
97 open(105, round
=round_(1), pad
='no', round
='nearest')
99 !ERROR: If NEWUNIT appears, UNIT must not appear
100 !ERROR: If NEWUNIT appears, FILE or STATUS must also appear
103 !ERROR: RECL value (-30) must be positive
104 open(107, recl
=40-70)
106 !ERROR: RECL value (-36) must be positive
107 open(108, recl
=- - (-36)) ! nonstandard
109 !ERROR: Invalid ACTION value 'reedwrite'
110 open(109, access
=Access
, action
='reedwrite', recl
=77)
112 !ERROR: Invalid ACTION value 'nonsense'
113 open(110, action
=''//'non'//'sense', recl
=77)
115 !ERROR: Invalid STATUS value 'cold'
116 open(111, status
='cold')
118 !ERROR: Invalid STATUS value 'Keep'
119 open(112, status
='Keep')
121 !ERROR: If STATUS='NEW' appears, FILE must also appear
122 open(113, status
='new')
124 !ERROR: If STATUS='REPLACE' appears, FILE must also appear
125 open(114, status
='replace')
127 !ERROR: If STATUS='SCRATCH' appears, FILE must not appear
128 open(115, file
='abc', status
='scratch')
130 !ERROR: If NEWUNIT appears, FILE or STATUS='SCRATCH' must also appear
131 open(newunit
=nn
, status
='old')
133 !ERROR: Unimplemented CARRIAGECONTROL value 'fortran'
134 open (unit
=116, file
='xfile', carriagecontrol
='fortran') ! nonstandard
136 !ERROR: Invalid CARRIAGECONTROL value 'nonsense'
137 open (unit
=116, file
='xfile', carriagecontrol
='nonsense') ! nonstandard