1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
4 ! Tests for defined input/output. See 12.6.4.8 and 15.4.3.2, and C777
9 procedure
, nopass
:: tbp
=>formattedReadProc
!Error, NOPASS not allowed
10 !ERROR: Defined input/output procedure 'tbp' may not have NOPASS attribute
11 generic
:: read(formatted
) => tbp
15 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
16 class(t
), intent(inout
) :: dtv
17 integer, intent(in
) :: unit
18 character(len
=*), intent(in
) :: iotype
19 integer, intent(in
) :: vlist(:)
20 integer, intent(out
) :: iostat
21 character(len
=*), intent(inout
) :: iomsg
32 procedure
, pass
:: tbp
=>formattedReadProc
33 !ERROR: Defined input/output procedure 'formattedreadproc' must have 6 dummy arguments rather than 5
34 generic
:: read(formatted
) => tbp
38 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
)
39 class(t
), intent(inout
) :: dtv
40 integer, intent(in
) :: unit
41 character(len
=*), intent(in
) :: iotype
42 integer, intent(in
) :: vlist(:)
43 integer, intent(out
) :: iostat
54 procedure
, pass
:: tbp
=>unformattedReadProc
55 !ERROR: Defined input/output procedure 'unformattedreadproc' must have 4 dummy arguments rather than 5
56 generic
:: read(unformatted
) => tbp
61 subroutine unformattedReadProc(dtv
, unit
, iostat
, iomsg
, iotype
)
62 class(t
), intent(inout
) :: dtv
63 integer, intent(in
) :: unit
64 integer, intent(out
) :: iostat
65 character(len
=*), intent(inout
) :: iomsg
66 integer, intent(out
) :: iotype
77 procedure
, pass
:: tbp
=>formattedReadProc
78 generic
:: read(formatted
) => tbp
82 !ERROR: Dummy argument 0 of 'formattedreadproc' must be a data object
83 !ERROR: Cannot use an alternate return as the passed-object dummy argument
84 subroutine formattedReadProc(*, unit
, iotype
, vlist
, iostat
, iomsg
)
85 !ERROR: Dummy argument 'unit' must be a data object
86 !ERROR: A dummy procedure without the POINTER attribute may not have an INTENT attribute
87 procedure(sin
), intent(in
) :: unit
88 character(len
=*), intent(in
) :: iotype
89 integer, intent(in
) :: vlist(:)
90 integer, intent(out
) :: iostat
91 character(len
=*), intent(inout
) :: iomsg
102 !ERROR: Passed-object dummy argument 'dtv' of procedure 'tbp' must be of type 't' but is 'INTEGER(4)'
103 procedure
, pass
:: tbp
=>formattedReadProc
104 generic
:: read(formatted
) => tbp
108 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
109 !ERROR: Dummy argument 'dtv' of a defined input/output procedure must have a derived type
110 integer, intent(inout
) :: dtv
! error, must be of type t
111 integer, intent(in
) :: unit
112 character(len
=*), intent(in
) :: iotype
113 integer, intent(in
) :: vlist(:)
114 integer, intent(out
) :: iostat
115 character(len
=*), intent(inout
) :: iomsg
123 interface read(formatted
)
124 procedure
:: formattedReadProc
128 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
129 !ERROR: Dummy argument 'dtv' of a defined input/output procedure must have a derived type
130 integer, intent(inout
) :: dtv
131 integer, intent(in
) :: unit
132 character(len
=*), intent(in
) :: iotype
! error, must be deferred
133 integer, intent(in
) :: vlist(:)
134 integer, intent(out
) :: iostat
135 character(len
=*), intent(inout
) :: iomsg
143 procedure
, pass
:: tbp
=>formattedReadProc
144 generic
:: read(formatted
) => tbp
148 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
149 !ERROR: Dummy argument 'dtv' of a defined input/output procedure must have intent 'INTENT(INOUT)'
150 class(t
), intent(in
) :: dtv
! Error, must be intent(inout)
151 integer, intent(in
) :: unit
152 character(len
=*), intent(in
) :: iotype
153 integer, intent(in
) :: vlist(:)
154 integer, intent(out
) :: iostat
155 character(len
=*), intent(inout
) :: iomsg
166 procedure
, pass
:: tbp
=>formattedWriteProc
167 generic
:: write(formatted
) => tbp
171 subroutine formattedWriteProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
172 !ERROR: Dummy argument 'dtv' of a defined input/output procedure must have intent 'INTENT(IN)'
173 class(t
), intent(inout
) :: dtv
! Error, must be intent(inout)
174 integer, intent(in
) :: unit
175 character(len
=*), intent(in
) :: iotype
176 integer, intent(in
) :: vlist(:)
177 integer, intent(out
) :: iostat
178 character(len
=*), intent(inout
) :: iomsg
189 procedure
, pass
:: tbp
=>formattedReadProc
190 generic
:: read(formatted
) => tbp
194 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
195 class(t
), intent(inout
) :: dtv
! Error, can't have attributes
196 !ERROR: Dummy argument 'unit' of a defined input/output procedure may not have any attributes
197 integer, pointer, intent(in
) :: unit
198 character(len
=*), intent(in
) :: iotype
199 integer, intent(in
) :: vlist(:)
200 integer, intent(out
) :: iostat
201 character(len
=*), intent(inout
) :: iomsg
212 procedure
, pass
:: tbp
=>formattedReadProc
213 generic
:: read(formatted
) => tbp
217 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
218 class(t
), intent(inout
) :: dtv
219 !ERROR: Dummy argument 'unit' of a defined input/output procedure must be an INTEGER of default KIND
220 real, intent(in
) :: unit
! Error, must be an integer
221 character(len
=*), intent(in
) :: iotype
222 integer, intent(in
) :: vlist(:)
223 integer, intent(out
) :: iostat
224 character(len
=*), intent(inout
) :: iomsg
235 procedure
, pass
:: tbp
=>formattedReadProc
236 generic
:: read(formatted
) => tbp
240 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
241 class(t
), intent(inout
) :: dtv
242 !ERROR: Dummy argument 'unit' of a defined input/output procedure must be an INTEGER of default KIND
243 integer(8), intent(in
) :: unit
! Error, must be default KIND
244 character(len
=*), intent(in
) :: iotype
245 integer, intent(in
) :: vlist(:)
246 integer, intent(out
) :: iostat
247 character(len
=*), intent(inout
) :: iomsg
258 procedure
, pass
:: tbp
=>formattedReadProc
259 generic
:: read(formatted
) => tbp
263 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
264 class(t
), intent(inout
) :: dtv
265 !ERROR: Dummy argument 'unit' of a defined input/output procedure must be a scalar
266 integer, dimension(22), intent(in
) :: unit
! Error, must be a scalar
267 character(len
=*), intent(in
) :: iotype
268 integer, intent(in
) :: vlist(:)
269 integer, intent(out
) :: iostat
270 character(len
=*), intent(inout
) :: iomsg
281 procedure
, pass
:: tbp
=>formattedReadProc
282 generic
:: read(formatted
) => tbp
286 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
287 class(t
), intent(inout
) :: dtv
288 !ERROR: Dummy argument 'unit' of a defined input/output procedure must have intent 'INTENT(IN)'
289 integer, intent(out
) :: unit
!Error, must be intent(in)
290 character(len
=*), intent(in
) :: iotype
291 integer, intent(in
) :: vlist(:)
292 integer, intent(out
) :: iostat
293 character(len
=*), intent(inout
) :: iomsg
304 procedure
, pass
:: tbp
=>formattedReadProc
305 generic
:: read(formatted
) => tbp
309 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
310 class(t
), intent(inout
) :: dtv
311 !ERROR: Dummy argument 'unit' of a defined input/output procedure must have intent 'INTENT(IN)'
312 integer :: unit
!Error, must be INTENT(IN)
313 character(len
=*), intent(in
) :: iotype
314 integer, intent(in
) :: vlist(:)
315 integer, intent(out
) :: iostat
316 character(len
=*), intent(inout
) :: iomsg
327 procedure
, pass
:: tbp
=>formattedReadProc
328 generic
:: read(formatted
) => tbp
332 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
333 class(t
), intent(inout
) :: dtv
334 integer, intent(in
) :: unit
335 !ERROR: Dummy argument 'iotype' of a defined input/output procedure must be assumed-length CHARACTER
336 character(len
=5), intent(in
) :: iotype
! Error, must be assumed length
337 integer, intent(in
) :: vlist(:)
338 integer, intent(out
) :: iostat
339 character(len
=*), intent(inout
) :: iomsg
350 procedure
, pass
:: tbp
=>formattedReadProc
351 generic
:: read(formatted
) => tbp
355 subroutine formattedReadProc(dtv
, unit
, iotype
, vlist
, iostat
, iomsg
)
356 class(t
), intent(inout
) :: dtv
357 integer, intent(in
) :: unit
358 character(len
=*), intent(in
) :: iotype
359 !ERROR: Dummy argument 'vlist' of a defined input/output procedure must be deferred shape
360 integer, intent(in
) :: vlist(5)
361 integer, intent(out
) :: iostat
362 character(len
=*), intent(inout
) :: iomsg
370 ! Test the same defined input/output procedure specified as a generic
374 procedure
:: formattedReadProc
377 interface read(formatted
)
378 module procedure formattedReadProc
382 subroutine formattedReadProc(dtv
,unit
,iotype
,v_list
,iostat
,iomsg
)
383 class(t
),intent(inout
) :: dtv
384 integer,intent(in
) :: unit
385 character(*),intent(in
) :: iotype
386 integer,intent(in
) :: v_list(:)
387 integer,intent(out
) :: iostat
388 character(*),intent(inout
) :: iomsg
389 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
395 ! Test the same defined input/output procedure specified as a type-bound
396 ! procedure and as a generic
400 procedure
:: formattedReadProc
401 generic
:: read(formatted
) => formattedReadProc
403 interface read(formatted
)
404 module procedure formattedReadProc
407 subroutine formattedReadProc(dtv
,unit
,iotype
,v_list
,iostat
,iomsg
)
408 class(t
),intent(inout
) :: dtv
409 integer,intent(in
) :: unit
410 character(*),intent(in
) :: iotype
411 integer,intent(in
) :: v_list(:)
412 integer,intent(out
) :: iostat
413 character(*),intent(inout
) :: iomsg
414 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
420 ! Test two different defined input/output procedures specified as a
421 ! type-bound procedure and as a generic for the same derived type
425 procedure
:: unformattedReadProc1
426 generic
:: read(unformatted
) => unformattedReadProc1
428 interface read(unformatted
)
429 module procedure unformattedReadProc
432 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
433 class(t
),intent(inout
) :: dtv
434 integer,intent(in
) :: unit
435 integer,intent(out
) :: iostat
436 character(*),intent(inout
) :: iomsg
437 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
440 !ERROR: Derived type 't' already has defined input/output procedure 'READUNFORMATTED'
441 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
442 class(t
),intent(inout
) :: dtv
443 integer,intent(in
) :: unit
444 integer,intent(out
) :: iostat
445 character(*),intent(inout
) :: iomsg
446 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
452 ! Test read and write defined input/output procedures specified as a
453 ! type-bound procedure and as a generic for the same derived type
457 procedure
:: unformattedReadProc
458 generic
:: read(unformatted
) => unformattedReadProc
460 interface read(unformatted
)
461 module procedure unformattedReadProc
463 interface write(unformatted
)
464 module procedure unformattedWriteProc
467 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
468 class(t
),intent(inout
) :: dtv
469 integer,intent(in
) :: unit
470 integer,intent(out
) :: iostat
471 character(*),intent(inout
) :: iomsg
472 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
475 subroutine unformattedWriteProc(dtv
,unit
,iostat
,iomsg
)
476 class(t
),intent(in
) :: dtv
477 integer,intent(in
) :: unit
478 integer,intent(out
) :: iostat
479 character(*),intent(inout
) :: iomsg
480 write(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
486 ! Test read and write defined input/output procedures specified as a
487 ! type-bound procedure and as a generic for the same derived type with a
488 ! KIND type parameter where they both have the same value
490 integer, kind
:: typeParam
= 4
493 procedure
:: unformattedReadProc
494 generic
:: read(unformatted
) => unformattedReadProc
496 interface read(unformatted
)
497 module procedure unformattedReadProc1
500 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
501 class(t
),intent(inout
) :: dtv
502 integer,intent(in
) :: unit
503 integer,intent(out
) :: iostat
504 character(*),intent(inout
) :: iomsg
505 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
508 !ERROR: Derived type 't' already has defined input/output procedure 'READUNFORMATTED'
509 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
510 class(t(4)),intent(inout
) :: dtv
511 integer,intent(in
) :: unit
512 integer,intent(out
) :: iostat
513 character(*),intent(inout
) :: iomsg
514 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
520 ! Test read and write defined input/output procedures specified as a
521 ! type-bound procedure and as a generic for the same derived type with a
522 ! KIND type parameter where they have different values
524 integer, kind
:: typeParam
= 4
527 procedure
:: unformattedReadProc
528 generic
:: read(unformatted
) => unformattedReadProc
530 interface read(unformatted
)
531 module procedure unformattedReadProc1
534 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
535 class(t
),intent(inout
) :: dtv
536 integer,intent(in
) :: unit
537 integer,intent(out
) :: iostat
538 character(*),intent(inout
) :: iomsg
539 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
542 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
543 class(t(3)),intent(inout
) :: dtv
544 integer,intent(in
) :: unit
545 integer,intent(out
) :: iostat
546 character(*),intent(inout
) :: iomsg
547 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
554 ! Test read and write defined input/output procedures specified as a
555 ! type-bound procedure and as a generic for the same derived type with a
556 ! LEN type parameter where they have different values
557 integer, len
:: typeParam
= 4
560 procedure
:: unformattedReadProc
561 generic
:: read(unformatted
) => unformattedReadProc
563 interface read(unformatted
)
564 module procedure unformattedReadProc1
567 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
568 class(t(*)),intent(inout
) :: dtv
569 integer,intent(in
) :: unit
570 integer,intent(out
) :: iostat
571 character(*),intent(inout
) :: iomsg
572 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
575 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
576 class(t(3)),intent(inout
) :: dtv
577 integer,intent(in
) :: unit
578 integer,intent(out
) :: iostat
579 character(*),intent(inout
) :: iomsg
580 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
586 ! Test read and write defined input/output procedures specified as a
587 ! type-bound procedure and as a generic for the same derived type with a
588 ! LEN type parameter where they have the same value
590 integer, len
:: typeParam
= 4
593 procedure
:: unformattedReadProc
594 generic
:: read(unformatted
) => unformattedReadProc
596 interface read(unformatted
)
597 module procedure unformattedReadProc1
600 subroutine unformattedReadProc(dtv
,unit
,iostat
,iomsg
)
601 class(t(*)),intent(inout
) :: dtv
602 integer,intent(in
) :: unit
603 integer,intent(out
) :: iostat
604 character(*),intent(inout
) :: iomsg
605 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c
608 !ERROR: Derived type 't' already has defined input/output procedure 'READUNFORMATTED'
609 subroutine unformattedReadProc1(dtv
,unit
,iostat
,iomsg
)
610 class(t(*)),intent(inout
) :: dtv
611 integer,intent(in
) :: unit
612 integer,intent(out
) :: iostat
613 character(*),intent(inout
) :: iomsg
614 read(unit
,iotype
,iostat
=iostat
,iomsg
=iomsg
) dtv
%c