| 1 |
! { dg-do compile } |
| 2 |
! |
| 3 |
! Check whether MODULE PROCEDUREs are properly treated |
| 4 |
! They need to be contained in a procedure, i.e. an |
| 5 |
! interface in another procedure is invalid; they may, however, |
| 6 |
! come from a use-associated procedure. |
| 7 |
! (The PROCEDURE statement allows also for non-module procedures |
| 8 |
! if there is an explicit interface.) |
| 9 |
! |
| 10 |
! PR fortran/33228 |
| 11 |
! |
| 12 |
module inclmod |
| 13 |
implicit none |
| 14 |
interface |
| 15 |
subroutine wrong1(a) |
| 16 |
integer :: a |
| 17 |
end subroutine wrong1 |
| 18 |
end interface |
| 19 |
interface gen_incl |
| 20 |
module procedure ok1 |
| 21 |
end interface gen_incl |
| 22 |
external wrong2 |
| 23 |
external wrong3 |
| 24 |
real wrong3 |
| 25 |
contains |
| 26 |
subroutine ok1(f) |
| 27 |
character :: f |
| 28 |
end subroutine ok1 |
| 29 |
end module inclmod |
| 30 |
|
| 31 |
module a |
| 32 |
use inclmod |
| 33 |
implicit none |
| 34 |
interface gen |
| 35 |
subroutine ok1_a(a,b) |
| 36 |
integer :: a,b |
| 37 |
end subroutine ok1_a |
| 38 |
module procedure ok1, ok2_a |
| 39 |
end interface gen |
| 40 |
contains |
| 41 |
subroutine ok2_a(a,b,c) |
| 42 |
integer :: a,b,c |
| 43 |
end subroutine ok2_a |
| 44 |
end module a |
| 45 |
|
| 46 |
module b |
| 47 |
use inclmod |
| 48 |
interface gen_wrong_0 |
| 49 |
module procedure gen_incl ! { dg-error "Cannot change attributes" } |
| 50 |
end interface gen_wrong_0 |
| 51 |
end module b |
| 52 |
|
| 53 |
module c |
| 54 |
use inclmod |
| 55 |
interface gen_wrong_1 |
| 56 |
module procedure wrong1 ! { dg-error "is not a module procedure" } |
| 57 |
end interface gen_wrong_1 |
| 58 |
end module c |
| 59 |
|
| 60 |
module d |
| 61 |
use inclmod |
| 62 |
interface gen_wrong_2 |
| 63 |
module procedure wrong2 ! { dg-error "Cannot change attributes" } |
| 64 |
end interface gen_wrong_2 |
| 65 |
end module d |
| 66 |
|
| 67 |
module e |
| 68 |
use inclmod |
| 69 |
interface gen_wrong_3 |
| 70 |
module procedure wrong3 ! { dg-error "Cannot change attributes" } |
| 71 |
end interface gen_wrong_3 |
| 72 |
end module e |
| 73 |
|
| 74 |
module f |
| 75 |
implicit none |
| 76 |
interface |
| 77 |
subroutine wrong_a(a) |
| 78 |
integer :: a |
| 79 |
end subroutine wrong_a |
| 80 |
end interface |
| 81 |
interface gen_wrong_4 |
| 82 |
module procedure wrong_a ! { dg-error "is not a module procedure" } |
| 83 |
end interface gen_wrong_4 |
| 84 |
end module f |
| 85 |
|
| 86 |
module g |
| 87 |
implicit none |
| 88 |
external wrong_b |
| 89 |
interface gen_wrong_5 |
| 90 |
module procedure wrong_b ! { dg-error "has no explicit interface" } |
| 91 |
end interface gen_wrong_5 |
| 92 |
end module g |
| 93 |
|
| 94 |
module h |
| 95 |
implicit none |
| 96 |
external wrong_c |
| 97 |
real wrong_c |
| 98 |
interface gen_wrong_6 |
| 99 |
module procedure wrong_c ! { dg-error "has no explicit interface" } |
| 100 |
end interface gen_wrong_6 |
| 101 |
end module h |
| 102 |
|
| 103 |
end |