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) {
1177
1177
}
1178
1178
}
1179
1179
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) {
1183
1182
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
+ }
1185
1188
}
1186
1189
}
1187
1190
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
+
1188
1201
void DoForallChecker::Leave (const parser::StatVariable &statVariable) {
1189
1202
context_.CheckIndexVarRedefine (statVariable.v .thing .thing );
1190
1203
}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ struct ForallStmt;
26
26
struct InquireSpec ;
27
27
struct IoControlSpec ;
28
28
struct OutputImpliedDo ;
29
+ struct InputImpliedDo ;
29
30
struct StatVariable ;
30
31
} // namespace Fortran::parser
31
32
@@ -55,6 +56,7 @@ class DoForallChecker : public virtual BaseChecker {
55
56
void Leave (const parser::InquireSpec &);
56
57
void Leave (const parser::IoControlSpec &);
57
58
void Leave (const parser::OutputImpliedDo &);
59
+ void Leave (const parser::InputImpliedDo &);
58
60
void Leave (const parser::StatVariable &);
59
61
60
62
private:
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