Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions flang/lib/Semantics/check-do-forall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,14 +1177,27 @@ void DoForallChecker::Leave(const parser::IoControlSpec &ioControlSpec) {
}
}

void DoForallChecker::Leave(const parser::OutputImpliedDo &outputImpliedDo) {
const auto &control{std::get<parser::IoImpliedDoControl>(outputImpliedDo.t)};
const parser::Name &name{control.name.thing.thing};
static void CheckIoImpliedDoIndex(
SemanticsContext &context, const parser::Name &name) {
if (name.symbol) {
context_.CheckIndexVarRedefine(name.source, *name.symbol);
context.CheckIndexVarRedefine(name.source, *name.symbol);
if (auto why{WhyNotDefinable(name.source, name.symbol->owner(),
DefinabilityFlags{}, *name.symbol)}) {
context.Say(std::move(*why));
}
}
}

void DoForallChecker::Leave(const parser::OutputImpliedDo &outputImpliedDo) {
CheckIoImpliedDoIndex(context_,
std::get<parser::IoImpliedDoControl>(outputImpliedDo.t).name.thing.thing);
}

void DoForallChecker::Leave(const parser::InputImpliedDo &inputImpliedDo) {
CheckIoImpliedDoIndex(context_,
std::get<parser::IoImpliedDoControl>(inputImpliedDo.t).name.thing.thing);
}

void DoForallChecker::Leave(const parser::StatVariable &statVariable) {
context_.CheckIndexVarRedefine(statVariable.v.thing.thing);
}
Expand Down
2 changes: 2 additions & 0 deletions flang/lib/Semantics/check-do-forall.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct ForallStmt;
struct InquireSpec;
struct IoControlSpec;
struct OutputImpliedDo;
struct InputImpliedDo;
struct StatVariable;
} // namespace Fortran::parser

Expand Down Expand Up @@ -55,6 +56,7 @@ class DoForallChecker : public virtual BaseChecker {
void Leave(const parser::InquireSpec &);
void Leave(const parser::IoControlSpec &);
void Leave(const parser::OutputImpliedDo &);
void Leave(const parser::InputImpliedDo &);
void Leave(const parser::StatVariable &);

private:
Expand Down
8 changes: 8 additions & 0 deletions flang/test/Semantics/definable07.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
integer, parameter :: j = 5
real a(5)
!ERROR: 'j' is not a variable
read *, (a(j), j=1, 5)
!ERROR: 'j' is not a variable
print *, (a(j), j=1, 5)
end
Loading