diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -846,7 +846,7 @@ bool AccAttributeVisitor::Pre(const parser::AccBindClause &x) { if (const auto *name{std::get_if(&x.u)}) { - if (!ResolveName(*name)) { + if (!ResolveName(*name, true)) { context_.Say(name->source, "No function or subroutine declared for '%s'"_err_en_US, name->source); diff --git a/flang/test/Semantics/OpenACC/acc-routine.f90 b/flang/test/Semantics/OpenACC/acc-routine.f90 --- a/flang/test/Semantics/OpenACC/acc-routine.f90 +++ b/flang/test/Semantics/OpenACC/acc-routine.f90 @@ -9,3 +9,7 @@ real, dimension(10) :: a call sub1(a) end subroutine + +subroutine sub3() + !$acc routine bind(sub1) +end subroutine