https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121182
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pault at gcc dot gnu.org
--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 61921
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61921&action=edit
Provisional patch for this PR
Development testcase:
module m
generic, public :: g => ig, rg
generic :: operator(.plus.) => ig, rg
generic, private :: h => ig, rg
contains
function rg (arg1, arg2)
real :: rg
real, intent(in) :: arg1, arg2
rg = arg1 + arg2
end
function ig (arg1, arg2)
integer :: ig
integer, intent(in) :: arg1, arg2
ig = arg1 + arg2
end
subroutine foo
real :: a = 1.0, b = 2.0
integer :: c = 3, d = 4
print *, "private in foo ", h(a,b), h(c,d)
print *, "operator in foo ", a.plus.b, c.plus.d
end
end module m
program p
use m
generic :: operator(.minus.) => pig, prg
generic :: operator(*) => times
generic :: j => ig, rg
type :: t
integer :: i
end type
real :: a = 1.0, b = 2.0
integer :: c = 3, d = 4
type(t) :: t1 = t(2), t2 = t(3), tres
print *, "module generic in p ", g(a,b), g(c,d)
print *, "local generic in p ", j(a,b), j(c,d)
print *, "module operator in p", a.plus.b, c.plus.d
print *, "local operator in p", a.minus.b, c.minus.d
block
generic :: operator(.bminus.) => pig, prg
print *, "local operator in block", a.bminus.b, c.bminus.d
end block
tres = t1 * t2
print *, "intrinsic operator in p ", tres%i
call foo
contains
function pig (arg1, arg2)
integer :: pig
integer, intent(in) :: arg1, arg2
pig = arg1 - arg2
end
function prg (arg1, arg2)
real :: prg
real, intent(in) :: arg1, arg2
prg = arg1 - arg2
end
function times (arg1, arg2) result(res)
type(t) :: res
type(t), intent(in) :: arg1, arg2
res%i = arg1%i * arg2%i
end
end