1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 ! Tests for defined input/output. See 12.6.4.8 and 15.4.3.2, and C777
8 procedure
, nopass
:: tbp
=>formattedReadProc
!Error, NOPASS not allowed
9 !ERROR: Defined input/output procedure 'tbp' may not have NOPASS attribute
10 generic
:: read(formatted
) => tbp
14 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
15 class(t
), intent(inout
) :: dtv
16 integer, intent(in
) :: unit
17 character(len
=*), intent(in
) :: iotype
18 integer, intent(in
) :: vlist(:)
19 integer, intent(out
) :: iostat
20 character(len
=*), intent(inout
) :: iomsg
31 procedure
, pass
:: tbp
=>formattedReadProc
32 !ERROR: Defined input/output procedure 'formattedreadproc' must have 6 dummy arguments rather than 5
33 generic
:: read(formatted
) => tbp
37 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
)
38 class(t
), intent(inout
) :: dtv
39 integer, intent(in
) :: unit
40 character(len
=*), intent(in
) :: iotype
41 integer, intent(in
) :: vlist(:)
42 integer, intent(out
) :: iostat
53 procedure
, pass
:: tbp
=>unformattedReadProc
54 !ERROR: Defined input/output procedure 'unformattedreadproc' must have 4 dummy arguments rather than 5
55 generic
:: read(unformatted
) => tbp
60 subroutine unformattedReadProc(dtv
, unit
, iostat
, iomsg
, iotype
)
61 class(t
), intent(inout
) :: dtv
62 integer, intent(in
) :: unit
63 integer, intent(out
) :: iostat
64 character(len
=*), intent(inout
) :: iomsg
65 integer, intent(out
) :: iotype
76 procedure
, pass
:: tbp
=>formattedReadProc
77 generic
:: read(formatted
) => tbp
81 !ERROR: Dummy argument 0 of 'formattedreadproc' must be a data object
82 !ERROR: Cannot use an alternate return as the passed-object dummy argument
83 subroutine formattedReadProc(*, unit
, iotype
, vlist
, iostat
, iomsg
)
84 !ERROR: Dummy argument 'unit' must be a data object
85 !ERROR: A dummy procedure without the POINTER attribute may not have an INTENT attribute
86 procedure(sin
), intent(in
) :: unit
87 character(len
=*), intent(in
) :: iotype
88 integer, intent(in
) :: vlist(:)
89 integer, intent(out
) :: iostat
90 character(len
=*), intent(inout
) :: iomsg
101 !ERROR: Passed-object dummy argument 'dtv' of procedure 'tbp' must be of type 't' but is 'INTEGER(4)'
102 procedure
, pass
:: tbp
=>formattedReadProc
103 generic
:: read(formatted
) => tbp
107 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
108 !ERROR: Dummy argument 'dtv' of a defined input/output procedure must have a derived type
109 integer, intent(inout
) :: dtv
! error, must be of type t
110 integer, intent(in
) :: unit
111 character(len
=*), intent(in
) :: iotype
112 integer, intent(in
) :: vlist(:)
113 integer, intent(out
) :: iostat
114 character(len
=*), intent(inout
) :: iomsg
122 interface read(formatted
)
123 procedure
:: formattedReadProc
127 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
128 !ERROR: Dummy argument 'dtv' of a defined input/output procedure must have a derived type
129 integer, intent(inout
) :: dtv
130 integer, intent(in
) :: unit
131 character(len
=*), intent(in
) :: iotype
! error, must be deferred
132 integer, intent(in
) :: vlist(:)
133 integer, intent(out
) :: iostat
134 character(len
=*), intent(inout
) :: iomsg
142 procedure
, pass
:: tbp
=>formattedReadProc
143 generic
:: read(formatted
) => tbp
147 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
148 !ERROR: Dummy argument 'dtv' of a defined input/output procedure must have intent 'INTENT(INOUT)'
149 class(t
), intent(in
) :: dtv
! Error, must be intent(inout)
150 integer, intent(in
) :: unit
151 character(len
=*), intent(in
) :: iotype
152 integer, intent(in
) :: vlist(:)
153 integer, intent(out
) :: iostat
154 character(len
=*), intent(inout
) :: iomsg
165 procedure
, pass
:: tbp
=>formattedWriteProc
166 generic
:: write(formatted
) => tbp
170 subroutine formattedWriteProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
171 !ERROR: Dummy argument 'dtv' of a defined input/output procedure must have intent 'INTENT(IN)'
172 class(t
), intent(inout
) :: dtv
! Error, must be intent(inout)
173 integer, intent(in
) :: unit
174 character(len
=*), intent(in
) :: iotype
175 integer, intent(in
) :: vlist(:)
176 integer, intent(out
) :: iostat
177 character(len
=*), intent(inout
) :: iomsg
188 procedure
, pass
:: tbp
=>formattedReadProc
189 generic
:: read(formatted
) => tbp
193 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
194 class(t
), intent(inout
) :: dtv
! Error, can't have attributes
195 !ERROR: Dummy argument 'unit' of a defined input/output procedure may not have any attributes
196 integer, pointer, intent(in
) :: unit
197 character(len
=*), intent(in
) :: iotype
198 integer, intent(in
) :: vlist(:)
199 integer, intent(out
) :: iostat
200 character(len
=*), intent(inout
) :: iomsg
211 procedure
, pass
:: tbp
=>formattedReadProc
212 generic
:: read(formatted
) => tbp
216 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
217 class(t
), intent(inout
) :: dtv
218 !ERROR: Dummy argument 'unit' of a defined input/output procedure must be an INTEGER of default KIND
219 real, intent(in
) :: unit
! Error, must be an integer
220 character(len
=*), intent(in
) :: iotype
221 integer, intent(in
) :: vlist(:)
222 integer, intent(out
) :: iostat
223 character(len
=*), intent(inout
) :: iomsg
234 procedure
, pass
:: tbp
=>formattedReadProc
235 generic
:: read(formatted
) => tbp
239 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
240 class(t
), intent(inout
) :: dtv
241 !ERROR: Dummy argument 'unit' of a defined input/output procedure must be an INTEGER of default KIND
242 integer(8), intent(in
) :: unit
! Error, must be default KIND
243 character(len
=*), intent(in
) :: iotype
244 integer, intent(in
) :: vlist(:)
245 integer, intent(out
) :: iostat
246 character(len
=*), intent(inout
) :: iomsg
257 procedure
, pass
:: tbp
=>formattedReadProc
258 generic
:: read(formatted
) => tbp
262 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
263 class(t
), intent(inout
) :: dtv
264 !ERROR: Dummy argument 'unit' of a defined input/output procedure must be a scalar
265 integer, dimension(22), intent(in
) :: unit
! Error, must be a scalar
266 character(len
=*), intent(in
) :: iotype
267 integer, intent(in
) :: vlist(:)
268 integer, intent(out
) :: iostat
269 character(len
=*), intent(inout
) :: iomsg
280 procedure
, pass
:: tbp
=>formattedReadProc
281 generic
:: read(formatted
) => tbp
285 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
286 class(t
), intent(inout
) :: dtv
287 !ERROR: Dummy argument 'unit' of a defined input/output procedure must have intent 'INTENT(IN)'
288 integer, intent(out
) :: unit
!Error, must be intent(in)
289 character(len
=*), intent(in
) :: iotype
290 integer, intent(in
) :: vlist(:)
291 integer, intent(out
) :: iostat
292 character(len
=*), intent(inout
) :: iomsg
303 procedure
, pass
:: tbp
=>formattedReadProc
304 generic
:: read(formatted
) => tbp
308 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
309 class(t
), intent(inout
) :: dtv
310 !ERROR: Dummy argument 'unit' of a defined input/output procedure must have intent 'INTENT(IN)'
311 integer :: unit
!Error, must be INTENT(IN)
312 character(len
=*), intent(in
) :: iotype
313 integer, intent(in
) :: vlist(:)
314 integer, intent(out
) :: iostat
315 character(len
=*), intent(inout
) :: iomsg
326 procedure
, pass
:: tbp
=>formattedReadProc
327 generic
:: read(formatted
) => tbp
331 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
332 class(t
), intent(inout
) :: dtv
333 integer, intent(in
) :: unit
334 !ERROR: Dummy argument 'iotype' of a defined input/output procedure must be assumed-length CHARACTER
335 character(len
=5), intent(in
) :: iotype
! Error, must be assumed length
336 integer, intent(in
) :: vlist(:)
337 integer, intent(out
) :: iostat
338 character(len
=*), intent(inout
) :: iomsg
349 procedure
, pass
:: tbp
=>formattedReadProc
350 generic
:: read(formatted
) => tbp
354 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
355 class(t
), intent(inout
) :: dtv
356 integer, intent(in
) :: unit
357 character(len
=*), intent(in
) :: iotype
358 !ERROR: Dummy argument 'vlist' of a defined input/output procedure must be deferred shape
359 integer, intent(in
) :: vlist(5)
360 integer, intent(out
) :: iostat
361 character(len
=*), intent(inout
) :: iomsg
369 ! Test the same defined input/output procedure specified as a generic
373 procedure
:: formattedReadProc
376 interface read(formatted
)
377 module procedure formattedReadProc
381 subroutine formattedReadProc(dtv
,unit
,iotype
,v_list
,iostat
,iomsg
)
382 class(t
),intent(inout
) :: dtv
383 integer,intent(in
) :: unit
384 character(*),intent(in
) :: iotype
385 integer,intent(in
) :: v_list(:)
386 integer,intent(out
) :: iostat
387 character(*),intent(inout
) :: iomsg
388 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
394 ! Test the same defined input/output procedure specified as a type-bound
395 ! procedure and as a generic
399 procedure
:: formattedReadProc
400 generic
:: read(formatted
) => formattedReadProc
402 interface read(formatted
)
403 module procedure formattedReadProc
406 subroutine formattedReadProc(dtv
,unit
,iotype
,v_list
,iostat
,iomsg
)
407 class(t
),intent(inout
) :: dtv
408 integer,intent(in
) :: unit
409 character(*),intent(in
) :: iotype
410 integer,intent(in
) :: v_list(:)
411 integer,intent(out
) :: iostat
412 character(*),intent(inout
) :: iomsg
413 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
419 ! Test two different defined input/output procedures specified as a
420 ! type-bound procedure and as a generic for the same derived type
424 procedure
:: unformattedReadProc1
425 generic
:: read(unformatted
) => unformattedReadProc1
427 interface read(unformatted
)
428 module procedure unformattedReadProc
431 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
432 class(t
),intent(inout
) :: dtv
433 integer,intent(in
) :: unit
434 integer,intent(out
) :: iostat
435 character(*),intent(inout
) :: iomsg
436 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
439 !ERROR: Derived type 't' already has defined input/output procedure 'READUNFORMATTED'
440 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
441 class(t
),intent(inout
) :: dtv
442 integer,intent(in
) :: unit
443 integer,intent(out
) :: iostat
444 character(*),intent(inout
) :: iomsg
445 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
451 ! Test read and write defined input/output procedures specified as a
452 ! type-bound procedure and as a generic for the same derived type
456 procedure
:: unformattedReadProc
457 generic
:: read(unformatted
) => unformattedReadProc
459 interface read(unformatted
)
460 module procedure unformattedReadProc
462 interface write(unformatted
)
463 module procedure unformattedWriteProc
466 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
467 class(t
),intent(inout
) :: dtv
468 integer,intent(in
) :: unit
469 integer,intent(out
) :: iostat
470 character(*),intent(inout
) :: iomsg
471 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
474 subroutine unformattedWriteProc(dtv
,unit
,iostat
,iomsg
)
475 class(t
),intent(in
) :: dtv
476 integer,intent(in
) :: unit
477 integer,intent(out
) :: iostat
478 character(*),intent(inout
) :: iomsg
479 write(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
485 ! Test read and write defined input/output procedures specified as a
486 ! type-bound procedure and as a generic for the same derived type with a
487 ! KIND type parameter where they both have the same value
489 integer, kind
:: typeParam
= 4
492 procedure
:: unformattedReadProc
493 generic
:: read(unformatted
) => unformattedReadProc
495 interface read(unformatted
)
496 module procedure unformattedReadProc1
499 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
500 class(t
),intent(inout
) :: dtv
501 integer,intent(in
) :: unit
502 integer,intent(out
) :: iostat
503 character(*),intent(inout
) :: iomsg
504 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
507 !ERROR: Derived type 't' already has defined input/output procedure 'READUNFORMATTED'
508 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
509 class(t(4)),intent(inout
) :: dtv
510 integer,intent(in
) :: unit
511 integer,intent(out
) :: iostat
512 character(*),intent(inout
) :: iomsg
513 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
519 ! Test read and write defined input/output procedures specified as a
520 ! type-bound procedure and as a generic for the same derived type with a
521 ! KIND type parameter where they have different values
523 integer, kind
:: typeParam
= 4
526 procedure
:: unformattedReadProc
527 generic
:: read(unformatted
) => unformattedReadProc
529 interface read(unformatted
)
530 module procedure unformattedReadProc1
533 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
534 class(t
),intent(inout
) :: dtv
535 integer,intent(in
) :: unit
536 integer,intent(out
) :: iostat
537 character(*),intent(inout
) :: iomsg
538 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
541 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
542 class(t(3)),intent(inout
) :: dtv
543 integer,intent(in
) :: unit
544 integer,intent(out
) :: iostat
545 character(*),intent(inout
) :: iomsg
546 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
553 ! Test read and write defined input/output procedures specified as a
554 ! type-bound procedure and as a generic for the same derived type with a
555 ! LEN type parameter where they have different values
556 integer, len
:: typeParam
= 4
559 procedure
:: unformattedReadProc
560 generic
:: read(unformatted
) => unformattedReadProc
562 interface read(unformatted
)
563 module procedure unformattedReadProc1
566 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
567 class(t(*)),intent(inout
) :: dtv
568 integer,intent(in
) :: unit
569 integer,intent(out
) :: iostat
570 character(*),intent(inout
) :: iomsg
571 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
574 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
575 class(t(3)),intent(inout
) :: dtv
576 integer,intent(in
) :: unit
577 integer,intent(out
) :: iostat
578 character(*),intent(inout
) :: iomsg
579 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
585 ! Test read and write defined input/output procedures specified as a
586 ! type-bound procedure and as a generic for the same derived type with a
587 ! LEN type parameter where they have the same value
589 integer, len
:: typeParam
= 4
592 procedure
:: unformattedReadProc
593 generic
:: read(unformatted
) => unformattedReadProc
595 interface read(unformatted
)
596 module procedure unformattedReadProc1
599 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
600 class(t(*)),intent(inout
) :: dtv
601 integer,intent(in
) :: unit
602 integer,intent(out
) :: iostat
603 character(*),intent(inout
) :: iomsg
604 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
607 !ERROR: Derived type 't' already has defined input/output procedure 'READUNFORMATTED'
608 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
609 class(t(*)),intent(inout
) :: dtv
610 integer,intent(in
) :: unit
611 integer,intent(out
) :: iostat
612 character(*),intent(inout
) :: iomsg
613 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c