3 ! Tests the fix for PR78108 in which an error was triggered by the
4 ! generic operator being resolved more than once in submodules. This
5 ! test checks that the error is triggered when the specific procedure
6 ! really is inserted more than once in the interface.
8 ! Note that adding the extra interface to the module produces two
9 ! errors; the one below and 'Duplicate EXTERNAL attribute specified at (1)'
11 ! Contributed by Damian Rouson <damian@sourceryinstitute.org>
19 generic :: operator(+) => add
21 generic :: operator(*) => mult
24 integer module function add(lhs,rhs)
26 class(foo), intent(in) :: lhs,rhs
28 integer module function mult(lhs,rhs)
30 class(foo), intent(in) :: lhs,rhs
34 submodule(foo_interface) foo_implementation
35 interface operator (+)
36 integer module function add(lhs,rhs)
38 class(foo), intent(in) :: lhs,rhs
39 end function ! { dg-error "is already present in the interface" }
42 integer module function add(lhs,rhs)
44 class(foo), intent(in) :: lhs,rhs
45 add = lhs % x + rhs % x
47 integer module function mult(lhs,rhs)
49 class(foo), intent(in) :: lhs,rhs
50 mult = lhs % x * rhs % x
55 type(foo) :: a = foo (42)
56 type(foo) :: b = foo (99)
57 if (a + b .ne. 141) call abort
58 if (a * b .ne. 4158) call abort