llvm-project/flang/test/Semantics/procinterface01.f90
Luke Ireland f1a8eae3b6 [flang] Port all remaining regression tests to lit
We have re-classified a subset of the regression tests as unit tests and
now we are porting the remaining ones.

Test discovery and running is now performed by lit rather than ctest.
The tests continue to use their original scripts with minor
modifications. Most of the changes were mechanical and so scripted.
A few changes were made by hand. Details

Manual:
  * modfile09-*.f90 tests depend on being run together as some tests have
    dependencies on modules created by other tests. This will need
     separating out when porting away from test_modfile.sh, but for now,
     added modfile09-*.f90 to the Inputs directory and added a single
     tests modfile09.f90 to hold the run line.
  * getdefinition03-a.f90 includes a non-test file getdefinition03-b.f90.
    Manually edited the former to find the latter in Inputs so as to add
    only one test.
  * Same pattern for getsymbols03-{a,b}.f90

Auto:
  * Remaining tests have a lit RUN line added to them based on the type
    of test they are.
  * Failing tests also have an XFAIL line added to them.
  * Generic tests have their pre-existing RUN lines replaced with the
    word "EXEC" to avoid conflict with the added lit RUN line.

Original-commit: flang-compiler/f18@63ec0af9f4
Reviewed-on: https://github.com/flang-compiler/f18/pull/1027
Tree-same-pre-rewrite: false
2020-03-13 11:58:11 +00:00

185 lines
6.0 KiB
Fortran

! RUN: %S/test_symbols.sh %s %flang %t
! Tests for "proc-interface" semantics.
! These cases are all valid.
!DEF: /module1 Module
module module1
abstract interface
!DEF: /module1/abstract1 PUBLIC (Function) Subprogram REAL(4)
!DEF: /module1/abstract1/x INTENT(IN) ObjectEntity REAL(4)
real function abstract1(x)
!REF: /module1/abstract1/x
real, intent(in) :: x
end function abstract1
end interface
interface
!DEF: /module1/explicit1 EXTERNAL, PUBLIC (Function) Subprogram REAL(4)
!DEF: /module1/explicit1/x INTENT(IN) ObjectEntity REAL(4)
real function explicit1(x)
!REF: /module1/explicit1/x
real, intent(in) :: x
end function explicit1
!DEF: /module1/logical EXTERNAL, PUBLIC (Function) Subprogram INTEGER(4)
!DEF: /module1/logical/x INTENT(IN) ObjectEntity REAL(4)
integer function logical(x)
!REF: /module1/logical/x
real, intent(in) :: x
end function logical
!DEF: /module1/tan EXTERNAL, PUBLIC (Function) Subprogram CHARACTER(1_4,1)
!DEF: /module1/tan/x INTENT(IN) ObjectEntity REAL(4)
character(len=1) function tan(x)
!REF: /module1/tan/x
real, intent(in) :: x
end function tan
end interface
!DEF: /module1/derived1 PUBLIC DerivedType
type :: derived1
!REF: /module1/abstract1
!DEF: /module1/derived1/p1 NOPASS, POINTER (Function) ProcEntity REAL(4)
!DEF: /module1/nested1 PUBLIC (Function) Subprogram REAL(4)
procedure(abstract1), pointer, nopass :: p1 => nested1
!REF: /module1/explicit1
!DEF: /module1/derived1/p2 NOPASS, POINTER (Function) ProcEntity REAL(4)
!REF: /module1/nested1
procedure(explicit1), pointer, nopass :: p2 => nested1
!DEF: /module1/derived1/p3 NOPASS, POINTER (Function) ProcEntity LOGICAL(4)
!DEF: /module1/nested2 PUBLIC (Function) Subprogram LOGICAL(4)
procedure(logical), pointer, nopass :: p3 => nested2
!DEF: /module1/derived1/p4 NOPASS, POINTER (Function) ProcEntity LOGICAL(4)
!DEF: /module1/nested3 PUBLIC (Function) Subprogram LOGICAL(4)
procedure(logical(kind=4)), pointer, nopass :: p4 => nested3
!DEF: /module1/derived1/p5 NOPASS, POINTER (Function) ProcEntity COMPLEX(4)
!DEF: /module1/nested4 PUBLIC (Function) Subprogram COMPLEX(4)
procedure(complex), pointer, nopass :: p5 => nested4
!DEF: /module1/sin ELEMENTAL, INTRINSIC, PUBLIC ProcEntity
!DEF: /module1/derived1/p6 NOPASS, POINTER ProcEntity
!REF: /module1/nested1
procedure(sin), pointer, nopass :: p6 => nested1
!REF: /module1/sin
!DEF: /module1/derived1/p7 NOPASS, POINTER ProcEntity
!DEF: /module1/cos ELEMENTAL, INTRINSIC, PUBLIC ProcEntity
procedure(sin), pointer, nopass :: p7 => cos
!REF: /module1/tan
!DEF: /module1/derived1/p8 NOPASS, POINTER (Function) ProcEntity CHARACTER(1_4,1)
!DEF: /module1/nested5 PUBLIC (Function) Subprogram CHARACTER(1_8,1)
procedure(tan), pointer, nopass :: p8 => nested5
end type derived1
contains
!REF: /module1/nested1
!DEF: /module1/nested1/x INTENT(IN) ObjectEntity REAL(4)
real function nested1(x)
!REF: /module1/nested1/x
real, intent(in) :: x
!DEF: /module1/nested1/nested1 ObjectEntity REAL(4)
!REF: /module1/nested1/x
nested1 = x+1.
end function nested1
!REF: /module1/nested2
!DEF: /module1/nested2/x INTENT(IN) ObjectEntity REAL(4)
logical function nested2(x)
!REF: /module1/nested2/x
real, intent(in) :: x
!DEF: /module1/nested2/nested2 ObjectEntity LOGICAL(4)
!REF: /module1/nested2/x
nested2 = x/=0
end function nested2
!REF: /module1/nested3
!DEF: /module1/nested3/x INTENT(IN) ObjectEntity REAL(4)
logical function nested3(x)
!REF: /module1/nested3/x
real, intent(in) :: x
!DEF: /module1/nested3/nested3 ObjectEntity LOGICAL(4)
!REF: /module1/nested3/x
nested3 = x>0
end function nested3
!REF: /module1/nested4
!DEF: /module1/nested4/x INTENT(IN) ObjectEntity REAL(4)
complex function nested4(x)
!REF: /module1/nested4/x
real, intent(in) :: x
!DEF: /module1/nested4/nested4 ObjectEntity COMPLEX(4)
!DEF: /module1/nested4/cmplx INTRINSIC (Function) ProcEntity
!REF: /module1/nested4/x
nested4 = cmplx(x+4., 6.)
end function nested4
!REF: /module1/nested5
!DEF: /module1/nested5/x INTENT(IN) ObjectEntity REAL(4)
character function nested5(x)
!REF: /module1/nested5/x
real, intent(in) :: x
!DEF: /module1/nested5/nested5 ObjectEntity CHARACTER(1_8,1)
nested5 = "a"
end function nested5
end module module1
!DEF: /explicit1 ELEMENTAL (Function) Subprogram REAL(4)
!DEF: /explicit1/x INTENT(IN) ObjectEntity REAL(4)
real elemental function explicit1(x)
!REF: /explicit1/x
real, intent(in) :: x
!DEF: /explicit1/explicit1 ObjectEntity REAL(4)
!REF: /explicit1/x
explicit1 = -x
end function explicit1
!DEF: /logical (Function) Subprogram INTEGER(4)
!DEF: /logical/x INTENT(IN) ObjectEntity REAL(4)
integer function logical(x)
!REF: /logical/x
real, intent(in) :: x
!DEF: /logical/logical ObjectEntity INTEGER(4)
!REF: /logical/x
logical = x+3.
end function logical
!DEF: /tan (Function) Subprogram REAL(4)
!DEF: /tan/x INTENT(IN) ObjectEntity REAL(4)
real function tan(x)
!REF: /tan/x
real, intent(in) :: x
!DEF: /tan/tan ObjectEntity REAL(4)
!REF: /tan/x
tan = x+5.
end function tan
!DEF: /main MainProgram
program main
!REF: /module1
use :: module1
!DEF: /main/derived1 Use
!DEF: /main/instance ObjectEntity TYPE(derived1)
type(derived1) :: instance
!REF: /main/instance
!REF: /module1/derived1/p1
if (instance%p1(1.)/=2.) print *, "p1 failed"
!REF: /main/instance
!REF: /module1/derived1/p2
if (instance%p2(1.)/=2.) print *, "p2 failed"
!REF: /main/instance
!REF: /module1/derived1/p3
if (.not.instance%p3(1.)) print *, "p3 failed"
!REF: /main/instance
!REF: /module1/derived1/p4
if (.not.instance%p4(1.)) print *, "p4 failed"
!REF: /main/instance
!REF: /module1/derived1/p5
if (instance%p5(1.)/=(5.,6.)) print *, "p5 failed"
!REF: /main/instance
!REF: /module1/derived1/p6
if (instance%p6(1.)/=2.) print *, "p6 failed"
!REF: /main/instance
!REF: /module1/derived1/p7
if (instance%p7(0.)/=1.) print *, "p7 failed"
!REF: /main/instance
!REF: /module1/derived1/p8
if (instance%p8(1.)/="a") print *, "p8 failed"
end program main