Peter Klausler cadc70c1f0
[flang] Prefer non-elemental to elemental defined operator resolution (#124941)
A non-elemental specific procedure must take precedence over an
elemental specific procedure in defined operator generic resolution.

Fixes https://github.com/llvm/llvm-project/issues/124777.
2025-01-31 10:54:00 -08:00

27 lines
546 B
Fortran

!RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s --allow-empty
!CHECK-NOT: error:
module m
type t
contains
procedure nonelemental
generic :: operator(+) => nonelemental
end type
interface operator(+)
procedure elemental
end interface
contains
type(t) elemental function elemental (a, b)
class(t), intent(in) :: a, b
elemental = t()
end
type(t) function nonelemental (a, b)
class(t), intent(in) :: a, b(:)
nonelemental = t()
end
end
program main
use m
type(t) x, y(1)
x = x + y ! ok
end