diff --git a/flang/lib/semantics/resolve-names.cc b/flang/lib/semantics/resolve-names.cc index 82cbcb6b292a..1482bf6e3fee 100644 --- a/flang/lib/semantics/resolve-names.cc +++ b/flang/lib/semantics/resolve-names.cc @@ -1039,7 +1039,6 @@ private: void SetTypeFromAssociation(Symbol &); void SetAttrsFromAssociation(Symbol &); Selector ResolveSelector(const parser::Selector &); - void ResolveControlExpressions(const parser::ConcurrentControl &control); void ResolveIndexName(const parser::ConcurrentControl &control); Association &GetCurrentAssociation(); void PushAssociation(); @@ -4605,41 +4604,19 @@ void ConstructVisitor::ResolveIndexName( EvaluateExpr(parser::Scalar{parser::Integer{common::Clone(name)}}); } -void ConstructVisitor::ResolveControlExpressions( - const parser::ConcurrentControl &control) { - Walk(std::get<1>(control.t)); // Initial expression - Walk(std::get<2>(control.t)); // Final expression - Walk(std::get<3>(control.t)); // Step expression -} - // We need to make sure that all of the index-names get declared before the // expressions in the loop control are evaluated so that references to the // index-names in the expressions are correctly detected. bool ConstructVisitor::Pre(const parser::ConcurrentHeader &header) { BeginDeclTypeSpec(); - - // Process the type spec, if present - const auto &typeSpec{ - std::get>(header.t)}; - if (typeSpec) { - SetDeclTypeSpec(MakeNumericType(TypeCategory::Integer, typeSpec->v)); - } - - // Process the index-name nodes in the ConcurrentControl nodes + Walk(std::get>(header.t)); const auto &controls{ std::get>(header.t)}; for (const auto &control : controls) { ResolveIndexName(control); } - - // Process the expressions in ConcurrentControls - for (const auto &control : controls) { - ResolveControlExpressions(control); - } - - // Resolve the names in the scalar-mask-expr + Walk(controls); Walk(std::get>(header.t)); - EndDeclTypeSpec(); return false; } diff --git a/flang/test/semantics/resolve35.f90 b/flang/test/semantics/resolve35.f90 index b7487557940c..bb93ab98131b 100644 --- a/flang/test/semantics/resolve35.f90 +++ b/flang/test/semantics/resolve35.f90 @@ -69,6 +69,16 @@ contains end end +subroutine s6b + integer, parameter :: k = 4 + integer :: l = 4 + forall(integer(k) :: i = 1:10) + end forall + !ERROR: Must be a constant value + forall(integer(l) :: i = 1:10) + end forall +end + subroutine s7 !ERROR: 'i' is already declared in this scoping unit do concurrent(integer::i=1:5) local(j, i) &