view gcc/testsuite/gfortran.dg/typebound_operator_16.f03 @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
line wrap: on
line source

! { 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