File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -194,14 +194,33 @@ void CoarrayChecker::Leave(const parser::SyncAllStmt &x) {
194194
195195void CoarrayChecker::Leave (const parser::SyncImagesStmt &x) {
196196 CheckSyncStatList (context_, std::get<std::list<parser::StatOrErrmsg>>(x.t ));
197-
198197 const auto &imageSet{std::get<parser::SyncImagesStmt::ImageSet>(x.t )};
199198 if (const auto *intExpr{std::get_if<parser::IntExpr>(&imageSet.u )}) {
200199 if (const auto *expr{GetExpr (context_, *intExpr)}) {
201200 if (expr->Rank () > 1 ) {
202201 context_.Say (parser::FindSourceLocation (imageSet), // C1174
203202 " An image-set that is an int-expr must be a scalar or a rank-one array" _err_en_US);
204203 }
204+ if (const auto *someInt{
205+ std::get_if<evaluate::Expr<evaluate::SomeInteger>>(&expr->u )};
206+ someInt && evaluate::IsActuallyConstant (*someInt)) {
207+ auto converted{evaluate::Fold (context_.foldingContext (),
208+ evaluate::ConvertToType<evaluate::SubscriptInteger>(
209+ common::Clone (*someInt)))};
210+ if (const auto *cst{
211+ evaluate::UnwrapConstantValue<evaluate::SubscriptInteger>(
212+ converted)}) {
213+ for (auto elt : cst->values ()) {
214+ auto n{elt.ToInt64 ()};
215+ if (n < 1 ) {
216+ context_.Say (parser::FindSourceLocation (imageSet),
217+ " Image number %jd in the image-set is not valid" _err_en_US,
218+ std::intmax_t {n});
219+ break ;
220+ }
221+ }
222+ }
223+ }
205224 }
206225 }
207226}
Original file line number Diff line number Diff line change 1+ ! RUN: %python %S/test_errors.py %s %flang_fc1
2+ integer twod(1 ,1 )
3+ sync images (* ) ! ok
4+ ! ERROR: An image-set that is an int-expr must be a scalar or a rank-one array
5+ sync images (twod)
6+ ! ERROR: Must have INTEGER type, but is REAL(4)
7+ sync images (3.14159 )
8+ ! ERROR: Image number -1 in the image-set is not valid
9+ sync images (- 1 )
10+ ! ERROR: Image number -1 in the image-set is not valid
11+ sync images ([2 , - 1 , 3 ])
12+ end
You can’t perform that action at this time.
0 commit comments