xref: /llvm-project/flang/test/Semantics/io13.f90 (revision 7ff9064b2609f2bcc8ca277f8cbb7f2f17d8e369)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Tests for UNIT=function()
3module m1
4  integer, target :: itarget
5  character(20), target :: ctarget
6  logical, target :: ltarget
7  interface gf
8    module procedure :: intf, pintf, pchf, logf, plogf
9  end interface
10 contains
11  integer function intf(n)
12    integer(1), intent(in) :: n
13    intf = n
14  end function
15  function pintf(n)
16    integer(2), intent(in) :: n
17    integer, pointer :: pintf
18    pintf => itarget
19    pintf = n
20  end function
21  function pchf(n)
22    integer(4), intent(in) :: n
23    character(:), pointer :: pchf
24    pchf => ctarget
25  end function
26  logical function logf(n)
27    integer(8), intent(in) :: n
28    logf = .true.
29  end function
30  function plogf(n)
31    integer(16), intent(in) :: n
32    logical, pointer :: plf
33    plf => ltarget
34  end function
35  subroutine test
36    write(intf(6_1),"('hi')")
37    write(pintf(6_2),"('hi')")
38    write(pchf(123_4),"('hi')")
39    write(gf(6_1),"('hi')")
40    write(gf(6_2),"('hi')")
41    write(gf(666_4),"('hi')")
42    !ERROR: I/O unit must be a character variable or a scalar integer expression
43    write(logf(666_8),"('hi')")
44    !ERROR: I/O unit must be a character variable or a scalar integer expression
45    write(plogf(666_16),"('hi')")
46    !ERROR: I/O unit must be a character variable or a scalar integer expression
47    write(gf(666_8),"('hi')")
48    !ERROR: I/O unit must be a character variable or a scalar integer expression
49    write(gf(666_16),"('hi')")
50    !ERROR: I/O unit must be a character variable or a scalar integer expression
51    write(null(),"('hi')")
52  end subroutine
53end module
54