100 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Tests module procedures declared and defined in the same module.3 4! These cases are correct.5module m16 interface7 integer module function f1(x)8 real, intent(in) :: x9 end function10 integer module function f2(x)11 real, intent(in) :: x12 end function13 module function f3(x) result(res)14 integer :: res15 real, intent(in) :: x16 end function17 module function f4(x) result(res)18 integer :: res19 real, intent(in) :: x20 end function21 module subroutine s122 end subroutine23 pure module subroutine s224 end subroutine25 module subroutine s326 end subroutine27 end interface28 contains29 integer module function f1(x)30 real, intent(in) :: x31 f1 = x32 end function33 module procedure f234 f2 = x35 end procedure36 module function f3(x) result(res)37 integer :: res38 real, intent(in) :: x39 res = x40 end function41 module procedure f442 res = x43 end procedure44 module subroutine s145 end subroutine46 pure module subroutine s247 end subroutine48 module procedure s349 end procedure50end module51 52! Error cases53 54module m255 interface56 integer module function f1(x)57 real, intent(in) :: x58 end function59 integer module function f2(x)60 real, intent(in) :: x61 end function62 module function f3(x) result(res)63 integer :: res64 real, intent(in) :: x65 end function66 module function f4(x) result(res)67 integer :: res68 real, intent(in) :: x69 end function70 module subroutine s171 end subroutine72 pure module subroutine s273 end subroutine74 end interface75 contains76 integer module function f1(x)77 !ERROR: Dummy argument 'x' has type INTEGER(4); the corresponding argument in the interface body has distinct type REAL(4)78 integer, intent(in) :: x79 f1 = x80 end function81 !ERROR: 'notf2' was not declared a separate module procedure82 module procedure notf283 end procedure84 !ERROR: Result of function 'f3' is not compatible with the result of the corresponding interface body: function results have distinct types: REAL(4) vs INTEGER(4)85 module function f3(x) result(res)86 real :: res87 real, intent(in) :: x88 res = x89 end function90 !ERROR: Module subroutine 'f4' was declared as a function in the corresponding interface body91 module subroutine f492 end subroutine93 !ERROR: Module function 's1' was declared as a subroutine in the corresponding interface body94 module function s195 end function96 !ERROR: Module subprogram 's2' and its corresponding interface body are not both PURE97 impure module subroutine s298 end subroutine99end module100