Peter Klausler 2d528fd7d7 [flang] Warn about defined operator with too few/many dummy arguments
A function in a defined operator generic interface will syntactically
have one or two arguments.  If a defined operator includes a specific
function with 0 or more than 2 dummy arguments, there's no way that it
could be invoked by way of the interface.  Emit a warning.

Differential Revision: https://reviews.llvm.org/D142762
2023-01-28 10:15:35 -08:00

29 lines
806 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! Warn about inaccessible specific procedures in a generic defined operator
module m
interface operator (.foo.)
!WARN: OPERATOR(.foo.) function 'noargs' must have 1 or 2 dummy arguments
module procedure noargs
!WARN: OPERATOR(.foo.) function 'noargs' must have 1 or 2 dummy arguments
module procedure threeargs
end interface
type t
contains
procedure :: bad
!WARN: OPERATOR(.bar.) function 'bad' should have 1 or 2 dummy arguments
generic :: operator (.bar.) => bad
end type
contains
real function noargs()
noargs = 0.
end
real function threeargs(fee,fie,foe)
real, intent(in) :: fee, fie, foe
end
function bad(this,x,y)
type(t) :: bad
class(t), intent(in) :: this, x, y
bad = x
end
end