diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp index cc1d4bf58745a..e258df86a4b1c 100644 --- a/flang/lib/Semantics/check-do-forall.cpp +++ b/flang/lib/Semantics/check-do-forall.cpp @@ -1180,7 +1180,9 @@ void DoForallChecker::Leave(const parser::IoControlSpec &ioControlSpec) { void DoForallChecker::Leave(const parser::OutputImpliedDo &outputImpliedDo) { const auto &control{std::get(outputImpliedDo.t)}; const parser::Name &name{control.name.thing.thing}; - context_.CheckIndexVarRedefine(name.source, *name.symbol); + if (name.symbol) { + context_.CheckIndexVarRedefine(name.source, *name.symbol); + } } void DoForallChecker::Leave(const parser::StatVariable &statVariable) { diff --git a/flang/test/Semantics/resolve40.f90 b/flang/test/Semantics/resolve40.f90 index a91507aa62282..81bb5f989ec48 100644 --- a/flang/test/Semantics/resolve40.f90 +++ b/flang/test/Semantics/resolve40.f90 @@ -96,3 +96,10 @@ subroutine s12(x) !BECAUSE: 'x' is an INTENT(IN) dummy argument read(*,nml=nl) end + +subroutine s13() + implicit none + !ERROR: No explicit type declared for 'i' + !ERROR: No explicit type declared for 'i' + print *, (i, i = 1, 2) +end