annotate gcc/testsuite/gfortran.dg/submodule_19.f08 @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! { dg-do compile }
kono
parents:
diff changeset
2 !
kono
parents:
diff changeset
3 ! Tests the fix for PR78108 in which an error was triggered by the
kono
parents:
diff changeset
4 ! generic operator being resolved more than once in submodules. This
kono
parents:
diff changeset
5 ! test checks that the error is triggered when the specific procedure
kono
parents:
diff changeset
6 ! really is inserted more than once in the interface.
kono
parents:
diff changeset
7 !
kono
parents:
diff changeset
8 ! Note that adding the extra interface to the module produces two
kono
parents:
diff changeset
9 ! errors; the one below and 'Duplicate EXTERNAL attribute specified at (1)'
kono
parents:
diff changeset
10 !
kono
parents:
diff changeset
11 ! Contributed by Damian Rouson <damian@sourceryinstitute.org>
kono
parents:
diff changeset
12 !
kono
parents:
diff changeset
13 module foo_interface
kono
parents:
diff changeset
14 implicit none
kono
parents:
diff changeset
15 type foo
kono
parents:
diff changeset
16 integer :: x
kono
parents:
diff changeset
17 contains
kono
parents:
diff changeset
18 procedure :: add
kono
parents:
diff changeset
19 generic :: operator(+) => add
kono
parents:
diff changeset
20 procedure :: mult
kono
parents:
diff changeset
21 generic :: operator(*) => mult
kono
parents:
diff changeset
22 end type
kono
parents:
diff changeset
23 interface
kono
parents:
diff changeset
24 integer module function add(lhs,rhs)
kono
parents:
diff changeset
25 implicit none
kono
parents:
diff changeset
26 class(foo), intent(in) :: lhs,rhs
kono
parents:
diff changeset
27 end function
kono
parents:
diff changeset
28 integer module function mult(lhs,rhs)
kono
parents:
diff changeset
29 implicit none
kono
parents:
diff changeset
30 class(foo), intent(in) :: lhs,rhs
kono
parents:
diff changeset
31 end function
kono
parents:
diff changeset
32 end interface
kono
parents:
diff changeset
33 end module
kono
parents:
diff changeset
34 submodule(foo_interface) foo_implementation
kono
parents:
diff changeset
35 interface operator (+)
kono
parents:
diff changeset
36 integer module function add(lhs,rhs)
kono
parents:
diff changeset
37 implicit none
kono
parents:
diff changeset
38 class(foo), intent(in) :: lhs,rhs
kono
parents:
diff changeset
39 end function ! { dg-error "is already present in the interface" }
kono
parents:
diff changeset
40 end interface
kono
parents:
diff changeset
41 contains
kono
parents:
diff changeset
42 integer module function add(lhs,rhs)
kono
parents:
diff changeset
43 implicit none
kono
parents:
diff changeset
44 class(foo), intent(in) :: lhs,rhs
kono
parents:
diff changeset
45 add = lhs % x + rhs % x
kono
parents:
diff changeset
46 end function
kono
parents:
diff changeset
47 integer module function mult(lhs,rhs)
kono
parents:
diff changeset
48 implicit none
kono
parents:
diff changeset
49 class(foo), intent(in) :: lhs,rhs
kono
parents:
diff changeset
50 mult = lhs % x * rhs % x
kono
parents:
diff changeset
51 end function
kono
parents:
diff changeset
52 end submodule
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 use foo_interface
kono
parents:
diff changeset
55 type(foo) :: a = foo (42)
kono
parents:
diff changeset
56 type(foo) :: b = foo (99)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
57 if (a + b .ne. 141) STOP 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
58 if (a * b .ne. 4158) STOP 2
111
kono
parents:
diff changeset
59 end