Index: flang/lib/Semantics/check-declarations.cpp =================================================================== --- flang/lib/Semantics/check-declarations.cpp +++ flang/lib/Semantics/check-declarations.cpp @@ -1901,10 +1901,20 @@ } } } - if (symbol.attrs().test(Attr::PRIVATE) && - overridden->attrs().test(Attr::PUBLIC)) { - SayWithDeclaration(*overridden, - "A PRIVATE procedure may not override a PUBLIC procedure"_err_en_US); + if (symbol.attrs().test(Attr::PRIVATE)) { + if (FindModuleContaining(dtScope) == + FindModuleContaining(overridden->owner())) { + // types declared in same madule + if (overridden->attrs().test(Attr::PUBLIC)) { + SayWithDeclaration(*overridden, + "A PRIVATE procedure may not override a PUBLIC procedure"_err_en_US); + } + } else { // types declared in distinct madules + if (!CheckAccessibleSymbol(dtScope.parent(), *overridden)) { + SayWithDeclaration(*overridden, + "A PRIVATE procedure may not override an accessible procedure"_err_en_US); + } + } } } else { SayWithDeclaration(*overridden, Index: flang/test/Semantics/bindings01.f90 =================================================================== --- flang/test/Semantics/bindings01.f90 +++ flang/test/Semantics/bindings01.f90 @@ -233,6 +233,48 @@ end subroutine end module +module m9 + type t1 + contains + procedure, public :: tbp => sub1 + end type + type, extends(t1) :: t2 + contains + !ERROR: A PRIVATE procedure may not override a PUBLIC procedure + procedure, private :: tbp => sub2 + end type + contains + subroutine sub1(x) + class(t1), intent(in) :: x + end subroutine + subroutine sub2(x) + class(t2), intent(in) :: x + end subroutine +end module + +module m10a + type t1 + contains + procedure :: tbp => sub1 + end type + contains + subroutine sub1(x) + class(t1), intent(in) :: x + end subroutine +end module +module m10b + use m10a + type, extends(t1) :: t2 + contains + !ERROR: A PRIVATE procedure may not override an accessible procedure + procedure, private :: tbp => sub2 + end type + contains + subroutine sub2(x) + class(t2), intent(in) :: x + end subroutine +end module + program test use m1 type,extends(t) :: t2