| 1 |
! { dg-do compile } |
| 2 |
|
| 3 |
! PR 24878 - passing a global subroutine as a function, or vice versa, |
| 4 |
! was not caught, nor were type mismatches. Original test case by |
| 5 |
! Uttam Pawar. |
| 6 |
|
| 7 |
program memain |
| 8 |
implicit none |
| 9 |
integer subr |
| 10 |
external subr |
| 11 |
external i4 |
| 12 |
external r4 |
| 13 |
integer r4 |
| 14 |
|
| 15 |
call foo(subr) ! { dg-error "Passing global subroutine" } |
| 16 |
call bar(i4) ! { dg-error "Passing global function" } |
| 17 |
call baz(r4) ! { dg-error "Type mismatch" } |
| 18 |
end program memain |
| 19 |
|
| 20 |
subroutine foo(ifun) |
| 21 |
integer(kind=4) ifun |
| 22 |
external ifun |
| 23 |
integer y |
| 24 |
!---FNC is not a Function subprogram so calling it |
| 25 |
! as a function is an error. |
| 26 |
Y=ifun(32) |
| 27 |
end subroutine foo |
| 28 |
|
| 29 |
subroutine bar(sub) |
| 30 |
call sub |
| 31 |
end subroutine bar |
| 32 |
|
| 33 |
subroutine subr(X) ! { dg-error "Passing global subroutine" } |
| 34 |
integer x |
| 35 |
x = 12345 |
| 36 |
end subroutine subr |
| 37 |
|
| 38 |
integer(kind=4) function i4() ! { dg-error "Passing global function" } |
| 39 |
i4 = 42 |
| 40 |
end function i4 |
| 41 |
|
| 42 |
real(kind=4) function r4() ! { dg-error "Type mismatch" } |
| 43 |
r4 = 1.0 |
| 44 |
end function r4 |
| 45 |
|
| 46 |
subroutine baz(ifun) |
| 47 |
integer(kind=4) ifun |
| 48 |
external ifun |
| 49 |
integer y |
| 50 |
y = ifun(32) |
| 51 |
end subroutine baz |