| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Tests the fix for PR78108 in which an error was |
| 4 |
! triggered by the module procedures being added twice |
| 5 |
! to the operator interfaces. |
| 6 |
! |
| 7 |
! Contributed by Damian Rouson <[email protected]> |
| 8 |
! |
| 9 |
module foo_interface |
| 10 |
implicit none |
| 11 |
type foo |
| 12 |
integer :: x |
| 13 |
contains |
| 14 |
procedure :: add |
| 15 |
generic :: operator(+) => add |
| 16 |
procedure :: mult |
| 17 |
generic :: operator(*) => mult |
| 18 |
end type |
| 19 |
interface |
| 20 |
integer module function add(lhs,rhs) |
| 21 |
implicit none |
| 22 |
class(foo), intent(in) :: lhs,rhs |
| 23 |
end function |
| 24 |
integer module function mult(lhs,rhs) |
| 25 |
implicit none |
| 26 |
class(foo), intent(in) :: lhs,rhs |
| 27 |
end function |
| 28 |
end interface |
| 29 |
end module |
| 30 |
submodule(foo_interface) foo_implementation |
| 31 |
contains |
| 32 |
integer module function add(lhs,rhs) |
| 33 |
implicit none |
| 34 |
class(foo), intent(in) :: lhs,rhs |
| 35 |
add = lhs % x + rhs % x |
| 36 |
end function |
| 37 |
integer module function mult(lhs,rhs) |
| 38 |
implicit none |
| 39 |
class(foo), intent(in) :: lhs,rhs |
| 40 |
mult = lhs % x * rhs % x |
| 41 |
end function |
| 42 |
end submodule |
| 43 |
|
| 44 |
use foo_interface |
| 45 |
type(foo) :: a = foo (42) |
| 46 |
type(foo) :: b = foo (99) |
| 47 |
if (a + b .ne. 141) STOP 1 |
| 48 |
if (a * b .ne. 4158) STOP 2 |
| 49 |
end |