mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 03:56:42 +00:00

An apparent attempt to override a type-bound procedure is not allowed to be interpreted as on override when the procedure is PRIVATE and the override attempt appears in another module. However, if the TBP that would have been overridden is a DEFERRED procedure in an abstract base type, the override must take place. PRIVATE DEFERRED procedures must therefore have all of their overrides appear in the same module as the abstract base type.
29 lines
704 B
Fortran
29 lines
704 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1
|
|
! Deferred TBPs must be overridden, but when they are private, those
|
|
! overrides must appear in the same module.
|
|
module m1
|
|
type, abstract :: absBase
|
|
contains
|
|
procedure(deferredInterface), deferred, private :: deferredTbp
|
|
end type
|
|
abstract interface
|
|
subroutine deferredInterface(x)
|
|
import absBase
|
|
class(absBase), intent(in) :: x
|
|
end
|
|
end interface
|
|
end
|
|
|
|
module m2
|
|
use m1
|
|
type, extends(absBase) :: ext
|
|
contains
|
|
!ERROR: Override of PRIVATE DEFERRED 'deferredtbp' must appear in its module
|
|
procedure :: deferredTbp => implTbp
|
|
end type
|
|
contains
|
|
subroutine implTbp(x)
|
|
class(ext), intent(in) :: x
|
|
end
|
|
end
|