aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/typebound_operator_16.f03
blob: eff43ebe53bddeb6f1690420a6091aa6e07e6792 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
! { dg-do compile }
!
! PR 49591: [OOP] Multiple identical specific procedures in type-bound operator not detected
!
! This is interpretation request F03/0018:
! http://www.j3-fortran.org/doc/meeting/195/11-214.txt
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>

module M1
  type T
    integer x
  contains
    procedure :: MyAdd_t => myadd
    generic :: operator(+) => myAdd_t
  end type T
  type X
    real q
  contains
    procedure, pass(b) :: MyAdd_x => myadd
    generic :: operator(+) => myAdd_x       ! { dg-error "is already present in the interface" }
  end type X
contains
  integer function MyAdd ( A, B )
    class(t), intent(in) :: A
    class(x), intent(in) :: B
    myadd = a%x + b%q
  end function MyAdd
end module

module M2
  interface operator(+)
    procedure MyAdd
  end interface
  type T
    integer x
  contains
    procedure :: MyAdd_t => myadd
    generic :: operator(+) => myAdd_t  ! { dg-error "is already present in the interface" }
  end type T
contains
  integer function MyAdd ( A, B )
    class(t), intent(in) :: A
    real, intent(in) :: B
    myadd = a%x + b
  end function MyAdd
end module

! { dg-final { cleanup-modules "M1 M2" } }