view gcc/testsuite/gfortran.dg/operator_2.f90 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

! { dg-do compile }
! Test that we can't override intrinsic operators in invalid ways
module foo

 interface operator(*)
  module procedure f1 ! { dg-error "conflicts with intrinsic interface" }
 end interface

 interface operator(>)
   module procedure f2 ! { dg-error "conflicts with intrinsic interface" }
 end interface

 interface operator(/)
  module procedure f3
 end interface

contains

 function f1(a,b) result (c)
  integer, intent(in) :: a
  integer, dimension(:), intent(in)   :: b
  integer, dimension(size(b,1))   :: c
  c = 0
 end function f1

 function f2(a,b)
   character(len=*), intent(in) :: a
   character(len=*), intent(in) :: b
   logical :: f2
   f2 = .false.
 end function f2

 function f3(a,b) result (c)
  integer, dimension(:,:), intent(in) :: a
  integer, dimension(:), intent(in)   :: b
  integer, dimension(size(b,1))   :: c
  c = 0
 end function f3

end