diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp --- a/flang/lib/Semantics/expression.cpp +++ b/flang/lib/Semantics/expression.cpp @@ -1700,6 +1700,9 @@ const parser::StructureComponent &sc{pcr.v.thing}; if (MaybeExpr base{Analyze(sc.base)}) { if (const Symbol * sym{sc.component.symbol}) { + if (context_.HasError(sym)) { + return std::nullopt; + } if (auto *dtExpr{UnwrapExpr>(*base)}) { if (sym->has()) { AdjustActuals adjustment{ 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 @@ -114,3 +114,28 @@ end subroutine s7 end module +module m1 + implicit none + interface g + module procedure mp + end interface g + + type t + contains + !ERROR: The binding of 'tbp' ('g') must be either an accessible module procedure or an external procedure with an explicit interface + procedure,pass(x) :: tbp => g + end type t + +contains + subroutine mp(x) + class(t),intent(in) :: x + end subroutine +end module m1 + +program test + use m1 + type,extends(t) :: t2 + end type + type(t2) a + call a%tbp +end program