194 lines · plain
1! RUN: %python %S/test_symbols.py %s %flang_fc12! Tests for "proc-interface" semantics.3! These cases are all valid.4 5!DEF: /module1 Module6module module17 !DEF:/module1/abstract2 ABSTRACT, POINTER, PUBLIC (Subroutine) Subprogram8 pointer :: abstract29 abstract interface10 !DEF: /module1/abstract1 ABSTRACT, PUBLIC (Function) Subprogram REAL(4)11 !DEF: /module1/abstract1/x INTENT(IN) ObjectEntity REAL(4)12 real function abstract1(x)13 !REF: /module1/abstract1/x14 real, intent(in) :: x15 end function abstract116 !REF:/module1/abstract217 subroutine abstract218 end subroutine19 !DEF:/module1/abstract3 ABSTRACT, POINTER, PUBLIC (Subroutine) Subprogram20 subroutine abstract321 end subroutine22 end interface23 !REF:/module1/abstract324 pointer :: abstract325 26 interface27 !DEF: /module1/explicit1 EXTERNAL, PUBLIC (Function) Subprogram REAL(4)28 !DEF: /module1/explicit1/x INTENT(IN) ObjectEntity REAL(4)29 real function explicit1(x)30 !REF: /module1/explicit1/x31 real, intent(in) :: x32 end function explicit133 !DEF: /module1/logical EXTERNAL, PUBLIC (Function) Subprogram INTEGER(4)34 !DEF: /module1/logical/x INTENT(IN) ObjectEntity REAL(4)35 integer function logical(x)36 !REF: /module1/logical/x37 real, intent(in) :: x38 end function logical39 !DEF: /module1/tan EXTERNAL, PUBLIC (Function) Subprogram CHARACTER(1_4,1)40 !DEF: /module1/tan/x INTENT(IN) ObjectEntity REAL(4)41 character(len=1) function tan(x)42 !REF: /module1/tan/x43 real, intent(in) :: x44 end function tan45 end interface46 47 !DEF: /module1/derived1 PUBLIC DerivedType48 type :: derived149 !REF: /module1/abstract150 !DEF: /module1/derived1/p1 NOPASS, POINTER (Function) ProcEntity REAL(4)51 !DEF: /module1/nested1 PUBLIC, PURE (Function) Subprogram REAL(4)52 procedure(abstract1), pointer, nopass :: p1 => nested153 !REF: /module1/explicit154 !DEF: /module1/derived1/p2 NOPASS, POINTER (Function) ProcEntity REAL(4)55 !REF: /module1/nested156 procedure(explicit1), pointer, nopass :: p2 => nested157 !DEF: /module1/derived1/p3 NOPASS, POINTER (Function) ProcEntity LOGICAL(4)58 !DEF: /module1/nested2 PUBLIC (Function) Subprogram LOGICAL(4)59 procedure(logical), pointer, nopass :: p3 => nested260 !DEF: /module1/derived1/p4 NOPASS, POINTER (Function) ProcEntity LOGICAL(4)61 !DEF: /module1/nested3 PUBLIC (Function) Subprogram LOGICAL(4)62 procedure(logical(kind=4)), pointer, nopass :: p4 => nested363 !DEF: /module1/derived1/p5 NOPASS, POINTER (Function) ProcEntity COMPLEX(4)64 !DEF: /module1/nested4 PUBLIC (Function) Subprogram COMPLEX(4)65 procedure(complex), pointer, nopass :: p5 => nested466 !DEF: /module1/sin ELEMENTAL, INTRINSIC, PUBLIC, PURE (Function) ProcEntity REAL(4)67 !DEF: /module1/derived1/p6 NOPASS, POINTER (Function) ProcEntity REAL(4)68 !REF: /module1/nested169 procedure(sin), pointer, nopass :: p6 => nested170 !REF: /module1/sin71 !DEF: /module1/derived1/p7 NOPASS, POINTER (Function) ProcEntity REAL(4)72 !DEF: /module1/cos ELEMENTAL, INTRINSIC, PUBLIC, PURE (Function) ProcEntity REAL(4)73 procedure(sin), pointer, nopass :: p7 => cos74 !REF: /module1/tan75 !DEF: /module1/derived1/p8 NOPASS, POINTER (Function) ProcEntity CHARACTER(1_4,1)76 !DEF: /module1/nested5 PUBLIC (Function) Subprogram CHARACTER(1_8,1)77 procedure(tan), pointer, nopass :: p8 => nested578 end type derived179 80contains81 82 !REF: /module1/nested183 !DEF: /module1/nested1/x INTENT(IN) ObjectEntity REAL(4)84 pure real function nested1(x)85 !REF: /module1/nested1/x86 real, intent(in) :: x87 !DEF: /module1/nested1/nested1 ObjectEntity REAL(4)88 !REF: /module1/nested1/x89 nested1 = x+1.90 end function nested191 92 !REF: /module1/nested293 !DEF: /module1/nested2/x INTENT(IN) ObjectEntity REAL(4)94 logical function nested2(x)95 !REF: /module1/nested2/x96 real, intent(in) :: x97 !DEF: /module1/nested2/nested2 ObjectEntity LOGICAL(4)98 !REF: /module1/nested2/x99 nested2 = x/=0100 end function nested2101 102 !REF: /module1/nested3103 !DEF: /module1/nested3/x INTENT(IN) ObjectEntity REAL(4)104 logical function nested3(x)105 !REF: /module1/nested3/x106 real, intent(in) :: x107 !DEF: /module1/nested3/nested3 ObjectEntity LOGICAL(4)108 !REF: /module1/nested3/x109 nested3 = x>0110 end function nested3111 112 !REF: /module1/nested4113 !DEF: /module1/nested4/x INTENT(IN) ObjectEntity REAL(4)114 complex function nested4(x)115 !REF: /module1/nested4/x116 real, intent(in) :: x117 !DEF: /module1/nested4/nested4 ObjectEntity COMPLEX(4)118 !DEF: /module1/nested4/cmplx ELEMENTAL, INTRINSIC, PURE (Function) ProcEntity119 !REF: /module1/nested4/x120 nested4 = cmplx(x+4., 6.)121 end function nested4122 123 !REF: /module1/nested5124 !DEF: /module1/nested5/x INTENT(IN) ObjectEntity REAL(4)125 character function nested5(x)126 !REF: /module1/nested5/x127 real, intent(in) :: x128 !DEF: /module1/nested5/nested5 ObjectEntity CHARACTER(1_8,1)129 nested5 = "a"130 end function nested5131end module module1132 133!DEF: /explicit1 (Function) Subprogram REAL(4)134!DEF: /explicit1/x INTENT(IN) ObjectEntity REAL(4)135real function explicit1(x)136 !REF: /explicit1/x137 real, intent(in) :: x138 !DEF: /explicit1/explicit1 ObjectEntity REAL(4)139 !REF: /explicit1/x140 explicit1 = -x141end function explicit1142 143!DEF: /logical (Function) Subprogram INTEGER(4)144!DEF: /logical/x INTENT(IN) ObjectEntity REAL(4)145integer function logical(x)146 !REF: /logical/x147 real, intent(in) :: x148 !DEF: /logical/logical ObjectEntity INTEGER(4)149 !REF: /logical/x150 logical = x+3.151end function logical152 153!DEF: /tan (Function) Subprogram CHARACTER(1_8,1)154!DEF: /tan/x INTENT(IN) ObjectEntity REAL(4)155character*1 function tan(x)156 !REF: /tan/x157 real, intent(in) :: x158 !DEF: /tan/tan ObjectEntity CHARACTER(1_8,1)159 tan = "?"160end function tan161 162!DEF: /MAIN MainProgram163program MAIN164 !REF: /module1165 use :: module1166 !DEF: /MAIN/derived1 Use167 !DEF: /MAIN/instance ObjectEntity TYPE(derived1)168 type(derived1) :: instance169 !REF: /MAIN/instance170 !REF: /module1/derived1/p1171 if (instance%p1(1.)/=2.) print *, "p1 failed"172 !REF: /MAIN/instance173 !REF: /module1/derived1/p2174 if (instance%p2(1.)/=2.) print *, "p2 failed"175 !REF: /MAIN/instance176 !REF: /module1/derived1/p3177 if (.not.instance%p3(1.)) print *, "p3 failed"178 !REF: /MAIN/instance179 !REF: /module1/derived1/p4180 if (.not.instance%p4(1.)) print *, "p4 failed"181 !REF: /MAIN/instance182 !REF: /module1/derived1/p5183 if (instance%p5(1.)/=(5.,6.)) print *, "p5 failed"184 !REF: /MAIN/instance185 !REF: /module1/derived1/p6186 if (instance%p6(1.)/=2.) print *, "p6 failed"187 !REF: /MAIN/instance188 !REF: /module1/derived1/p7189 if (instance%p7(0.)/=1.) print *, "p7 failed"190 !REF: /MAIN/instance191 !REF: /module1/derived1/p8192 if (instance%p8(1.)/="a") print *, "p8 failed"193end program MAIN194