fix pr/45972
[official-gcc.git] / gcc / testsuite / gfortran.dg / module_procedure_1.f90
blob5e1fa15c729fcffb32f8ce241a0e05c5e4484ac9
1 ! { dg-do run }
2 ! Modified program from http://groups.google.com/group/\
3 ! comp.lang.fortran/browse_frm/thread/423e4392dc965ab7#
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
15 program test_interface
17 use myoperator
19 implicit none
21 interface operator (.myadd.)
22 module procedure dadd
23 end interface
25 integer input1(2), input2(2), mysum(2)
27 input1 = (/0,1/)
28 input2 = (/3,3/)
29 mysum = input1 .myadd. input2
30 if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort
32 call test_sub(input1, input2)
34 end program test_interface
36 subroutine test_sub(input1, input2)
38 use myoperator
40 implicit none
42 interface operator (.myadd.)
43 module procedure dadd
44 end interface
46 integer, intent(in) :: input1(2), input2(2)
47 integer mysum(2)
49 mysum = input1 .myadd. input2
50 if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort
52 end subroutine test_sub
53 ! { dg-final { cleanup-modules "myoperator" } }