diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -1983,7 +1983,7 @@ if (FindModuleContaining(dtScope) == FindModuleContaining(overridden->owner())) { // types declared in same madule - if (overridden->attrs().test(Attr::PUBLIC)) { + if (!overridden->attrs().test(Attr::PRIVATE)) { SayWithDeclaration(*overridden, "A PRIVATE procedure may not override a PUBLIC procedure"_err_en_US); } diff --git a/flang/test/Semantics/bindings01.f90 b/flang/test/Semantics/bindings01.f90 --- a/flang/test/Semantics/bindings01.f90 +++ b/flang/test/Semantics/bindings01.f90 @@ -275,6 +275,24 @@ end subroutine end module +module m11 + type t1 + contains + procedure, nopass :: tbp => t1p + end type + type, extends(t1) :: t2 + contains + private + !ERROR: A PRIVATE procedure may not override a PUBLIC procedure + procedure, nopass :: tbp => t2p + end type + contains + subroutine t1p + end + subroutine t2p + end +end + program test use m1 type,extends(t) :: t2