1! RUN: %python %S/test_errors.py %s %flang_fc1 2! Tests module procedures declared and defined in the same module. 3 4! These cases are correct. 5module m1 6 interface 7 integer module function f1(x) 8 real, intent(in) :: x 9 end function 10 integer module function f2(x) 11 real, intent(in) :: x 12 end function 13 module function f3(x) result(res) 14 integer :: res 15 real, intent(in) :: x 16 end function 17 module function f4(x) result(res) 18 integer :: res 19 real, intent(in) :: x 20 end function 21 module subroutine s1 22 end subroutine 23 pure module subroutine s2 24 end subroutine 25 module subroutine s3 26 end subroutine 27 end interface 28 contains 29 integer module function f1(x) 30 real, intent(in) :: x 31 f1 = x 32 end function 33 module procedure f2 34 f2 = x 35 end procedure 36 module function f3(x) result(res) 37 integer :: res 38 real, intent(in) :: x 39 res = x 40 end function 41 module procedure f4 42 res = x 43 end procedure 44 module subroutine s1 45 end subroutine 46 pure module subroutine s2 47 end subroutine 48 module procedure s3 49 end procedure 50end module 51 52! Error cases 53 54module m2 55 interface 56 integer module function f1(x) 57 real, intent(in) :: x 58 end function 59 integer module function f2(x) 60 real, intent(in) :: x 61 end function 62 module function f3(x) result(res) 63 integer :: res 64 real, intent(in) :: x 65 end function 66 module function f4(x) result(res) 67 integer :: res 68 real, intent(in) :: x 69 end function 70 module subroutine s1 71 end subroutine 72 pure module subroutine s2 73 end subroutine 74 end interface 75 contains 76 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) :: x 79 f1 = x 80 end function 81 !ERROR: 'notf2' was not declared a separate module procedure 82 module procedure notf2 83 end procedure 84 !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 :: res 87 real, intent(in) :: x 88 res = x 89 end function 90 !ERROR: Module subroutine 'f4' was declared as a function in the corresponding interface body 91 module subroutine f4 92 end subroutine 93 !ERROR: Module function 's1' was declared as a subroutine in the corresponding interface body 94 module function s1 95 end function 96 !ERROR: Module subprogram 's2' and its corresponding interface body are not both PURE 97 impure module subroutine s2 98 end subroutine 99end module 100