File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -1177,14 +1177,27 @@ void DoForallChecker::Leave(const parser::IoControlSpec &ioControlSpec) {
11771177 }
11781178}
11791179
1180- void DoForallChecker::Leave (const parser::OutputImpliedDo &outputImpliedDo) {
1181- const auto &control{std::get<parser::IoImpliedDoControl>(outputImpliedDo.t )};
1182- const parser::Name &name{control.name .thing .thing };
1180+ static void CheckIoImpliedDoIndex (
1181+ SemanticsContext &context, const parser::Name &name) {
11831182 if (name.symbol ) {
1184- context_.CheckIndexVarRedefine (name.source , *name.symbol );
1183+ context.CheckIndexVarRedefine (name.source , *name.symbol );
1184+ if (auto why{WhyNotDefinable (name.source , name.symbol ->owner (),
1185+ DefinabilityFlags{}, *name.symbol )}) {
1186+ context.Say (std::move (*why));
1187+ }
11851188 }
11861189}
11871190
1191+ void DoForallChecker::Leave (const parser::OutputImpliedDo &outputImpliedDo) {
1192+ CheckIoImpliedDoIndex (context_,
1193+ std::get<parser::IoImpliedDoControl>(outputImpliedDo.t ).name .thing .thing );
1194+ }
1195+
1196+ void DoForallChecker::Leave (const parser::InputImpliedDo &inputImpliedDo) {
1197+ CheckIoImpliedDoIndex (context_,
1198+ std::get<parser::IoImpliedDoControl>(inputImpliedDo.t ).name .thing .thing );
1199+ }
1200+
11881201void DoForallChecker::Leave (const parser::StatVariable &statVariable) {
11891202 context_.CheckIndexVarRedefine (statVariable.v .thing .thing );
11901203}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ struct ForallStmt;
2626struct InquireSpec ;
2727struct IoControlSpec ;
2828struct OutputImpliedDo ;
29+ struct InputImpliedDo ;
2930struct StatVariable ;
3031} // namespace Fortran::parser
3132
@@ -55,6 +56,7 @@ class DoForallChecker : public virtual BaseChecker {
5556 void Leave (const parser::InquireSpec &);
5657 void Leave (const parser::IoControlSpec &);
5758 void Leave (const parser::OutputImpliedDo &);
59+ void Leave (const parser::InputImpliedDo &);
5860 void Leave (const parser::StatVariable &);
5961
6062private:
Original file line number Diff line number Diff line change 1+ ! RUN: %python %S/test_errors.py %s %flang_fc1
2+ integer , parameter :: j = 5
3+ real a(5 )
4+ ! ERROR: 'j' is not a variable
5+ read * , (a(j), j= 1 , 5 )
6+ ! ERROR: 'j' is not a variable
7+ print * , (a(j), j= 1 , 5 )
8+ end
You can’t perform that action at this time.
0 commit comments