| 1 |
! { dg-do run } |
| 2 |
! Modified program from http://groups.google.com/group/\ |
| 3 |
! comp.lang.fortran/browse_frm/thread/423e4392dc965ab7# |
| 4 |
! |
| 5 |
module myoperator |
| 6 |
contains |
| 7 |
function dadd(arg1,arg2) |
| 8 |
integer ::dadd(2) |
| 9 |
integer, intent(in) :: arg1(2), arg2(2) |
| 10 |
dadd(1)=arg1(1)+arg2(1) |
| 11 |
dadd(2)=arg1(2)+arg2(2) |
| 12 |
end function dadd |
| 13 |
end module myoperator |
| 14 |
|
| 15 |
program test_interface |
| 16 |
|
| 17 |
use myoperator |
| 18 |
|
| 19 |
implicit none |
| 20 |
|
| 21 |
interface operator (.myadd.) |
| 22 |
module procedure dadd |
| 23 |
end interface |
| 24 |
|
| 25 |
integer input1(2), input2(2), mysum(2) |
| 26 |
|
| 27 |
input1 = (/0,1/) |
| 28 |
input2 = (/3,3/) |
| 29 |
mysum = input1 .myadd. input2 |
| 30 |
if (mysum(1) /= 3 .and. mysum(2) /= 4) STOP 1 |
| 31 |
|
| 32 |
call test_sub(input1, input2) |
| 33 |
|
| 34 |
end program test_interface |
| 35 |
|
| 36 |
subroutine test_sub(input1, input2) |
| 37 |
|
| 38 |
use myoperator |
| 39 |
|
| 40 |
implicit none |
| 41 |
|
| 42 |
interface operator (.myadd.) |
| 43 |
module procedure dadd |
| 44 |
end interface |
| 45 |
|
| 46 |
integer, intent(in) :: input1(2), input2(2) |
| 47 |
integer mysum(2) |
| 48 |
|
| 49 |
mysum = input1 .myadd. input2 |
| 50 |
if (mysum(1) /= 3 .and. mysum(2) /= 4) STOP 2 |
| 51 |
|
| 52 |
end subroutine test_sub |