Change how generic operators and assignments are checked for distinguishable procedures. Because of how they are invoked, available type-bound generics and normal generics all have to be considered together. This is different from how generic names are checked. Move common part of checking into DistinguishabilityHelper so that it can be used in both cases after the appropriate procedures have been added. Cache result of Procedure::Characterize(Symbol) in a map in CheckHelper so that we don't have to worry about passing the characterized Procedures around or the cost of recomputing them. Add MakeOpName() to construct names for defined operators and assignment for using in error messages. This eliminates the need for different messages in those cases. When the procedures for a defined operator or assignment are undistinguishable, include the type name in the error message, otherwise it may be ambiguous. Add missing check that procedures for defined operators are functions and that their dummy arguments are INTENT(IN) or VALUE. Differential Revision: https://reviews.llvm.org/D87341
38 lines
822 B
Fortran
38 lines
822 B
Fortran
! RUN: %S/test_errors.sh %s %t %f18
|
|
module m
|
|
real :: var
|
|
interface i
|
|
!ERROR: 'var' is not a subprogram
|
|
procedure :: sub, var
|
|
!ERROR: Procedure 'bad' not found
|
|
procedure :: bad
|
|
end interface
|
|
interface operator(.foo.)
|
|
!ERROR: 'var' is not a subprogram
|
|
procedure :: var
|
|
!ERROR: OPERATOR(.foo.) procedure 'sub' must be a function
|
|
procedure :: sub
|
|
!ERROR: Procedure 'bad' not found
|
|
procedure :: bad
|
|
end interface
|
|
contains
|
|
subroutine sub
|
|
end
|
|
end
|
|
|
|
subroutine s
|
|
interface i
|
|
!ERROR: 'sub' is not a module procedure
|
|
module procedure :: sub
|
|
end interface
|
|
interface assignment(=)
|
|
!ERROR: 'sub' is not a module procedure
|
|
module procedure :: sub
|
|
end interface
|
|
contains
|
|
subroutine sub(x, y)
|
|
real, intent(out) :: x
|
|
logical, intent(in) :: y
|
|
end
|
|
end
|