brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 3384b05 Raw
163 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12integer :: y3procedure() :: a4procedure(real) :: b5call a  ! OK - can be function or subroutine6!ERROR: Cannot call subroutine 'a' like a function7c = a()8!ERROR: Cannot call function 'b' like a subroutine9call b10!ERROR: Cannot call function 'y' like a subroutine11call y12call x13!ERROR: Cannot call subroutine 'x' like a function14z = x()15end16 17subroutine s18  !ERROR: Cannot call function 'f' like a subroutine19  call f20  !ERROR: Cannot call subroutine 's' like a function21  i = s()22contains23  function f()24  end25end26 27subroutine s228  ! subroutine vs. function is determined by use29  external :: a, b30  call a()31  !ERROR: Cannot call subroutine 'a' like a function32  x = a()33  x = b()34  !ERROR: Cannot call function 'b' like a subroutine35  call b()36end37 38subroutine s339  ! subroutine vs. function is determined by use, even in internal subprograms40  external :: a41  procedure() :: b42contains43  subroutine s3a()44    x = a()45    call b()46  end47  subroutine s3b()48    !ERROR: Cannot call function 'a' like a subroutine49    call a()50    !ERROR: Cannot call subroutine 'b' like a function51    x = b()52  end53end54 55module m156  !Function vs subroutine in a module is resolved to a subroutine if57  !no other information.58  external :: exts, extf, extunk59  procedure() :: procs, procf, procunk60contains61  subroutine s62    call exts()63    call procs()64    x = extf()65    x = procf()66  end67end68 69module m270  use m171 contains72  subroutine test73    call exts() ! ok74    call procs() ! ok75    call extunk() ! ok76    call procunk() ! ok77    x = extf() ! ok78    x = procf() ! ok79    !ERROR: Cannot call subroutine 'extunk' like a function80    !ERROR: Function result characteristics are not known81    x = extunk()82    !ERROR: Cannot call subroutine 'procunk' like a function83    !ERROR: Function result characteristics are not known84    x = procunk()85  end86end87 88module modulename89end90 91! Call to entity in global scope, even with IMPORT, NONE92subroutine s493  block94    import, none95    integer :: i96    !ERROR: 'modulename' is not a callable procedure97    call modulename()98  end block99end100 101! Call to entity in global scope, even with IMPORT, NONE102subroutine s5103  block104    import, none105    integer :: i106    i = foo()107    !ERROR: Cannot call function 'foo' like a subroutine108    call foo()109  end block110end111 112subroutine s6113  call a6()114end115!ERROR: 'a6' was previously called as a subroutine116function a6()117  a6 = 0.0118end119 120subroutine s7121  x = a7()122end123!ERROR: 'a7' was previously called as a function124subroutine a7()125end126 127!OK: use of a8 and b8 is consistent128subroutine s8129  call a8()130  x = b8()131end132subroutine a8()133end134function b8()135  b8 = 0.0136end137 138subroutine s9139  type t140    procedure(), nopass, pointer :: p1, p2141  end type142  type(t) x143  !ERROR: Function result characteristics are not known144  print *, x%p1()145  call x%p2 ! ok146  call x%p1 ! ok147  !ERROR: Function result characteristics are not known148  print *, x%p2()149end subroutine150 151subroutine s10152  call a10153  !ERROR: Actual argument for 'a=' may not be a procedure154  print *, abs(a10)155end156 157subroutine s11158  real, pointer :: p(:)159  !ERROR: A NULL() pointer is not allowed for 'a=' intrinsic argument160  print *, rank(null())161  print *, rank(null(mold=p)) ! ok162end163