@@ -285,19 +285,32 @@ class DoConcurrentBodyEnforce {
285
285
.Attach (doConcurrentSourcePosition_, GetEnclosingDoMsg ());
286
286
}
287
287
288
- // C1139: call to impure procedure and ...
289
- // C1141: cannot call ieee_get_flag, ieee_[gs]et_halting_mode
290
- // It's not necessary to check the ieee_get* procedures because they're
291
- // not pure, and impure procedures are caught by checks for constraint C1139
288
+ // C1145, C1146: cannot call ieee_[gs]et_flag, ieee_[gs]et_halting_mode,
289
+ // ieee_[gs]et_status, ieee_set_rounding_mode, or ieee_set_underflow_mode
292
290
void Post (const parser::ProcedureDesignator &procedureDesignator) {
293
291
if (auto *name{std::get_if<parser::Name>(&procedureDesignator.u )}) {
294
- if (name->symbol &&
295
- fromScope (*name->symbol , " __fortran_ieee_exceptions" s)) {
296
- if (name->source == " ieee_set_halting_mode" ) {
297
- SayWithDo (context_, currentStatementSourcePosition_,
298
- " IEEE_SET_HALTING_MODE is not allowed in DO "
299
- " CONCURRENT" _err_en_US,
300
- doConcurrentSourcePosition_);
292
+ if (name->symbol ) {
293
+ const Symbol &ultimate{name->symbol ->GetUltimate ()};
294
+ const Scope &scope{ultimate.owner ()};
295
+ if (const Symbol * module {scope.IsModule () ? scope.symbol () : nullptr };
296
+ module &&
297
+ (module ->name () == " __fortran_ieee_arithmetic" ||
298
+ module ->name () == " __fortran_ieee_exceptions" )) {
299
+ std::string s{ultimate.name ().ToString ()};
300
+ static constexpr const char *badName[]{" ieee_get_flag" ,
301
+ " ieee_set_flag" , " ieee_get_halting_mode" , " ieee_set_halting_mode" ,
302
+ " ieee_get_status" , " ieee_set_status" , " ieee_set_rounding_mode" ,
303
+ " ieee_set_underflow_mode" , nullptr };
304
+ for (std::size_t j{0 }; badName[j]; ++j) {
305
+ if (s.find (badName[j]) != s.npos ) {
306
+ context_
307
+ .Say (name->source ,
308
+ " '%s' may not be called in DO CONCURRENT" _err_en_US,
309
+ badName[j])
310
+ .Attach (doConcurrentSourcePosition_, GetEnclosingDoMsg ());
311
+ break ;
312
+ }
313
+ }
301
314
}
302
315
}
303
316
}
@@ -318,15 +331,6 @@ class DoConcurrentBodyEnforce {
318
331
}
319
332
320
333
private:
321
- bool fromScope (const Symbol &symbol, const std::string &moduleName) {
322
- if (symbol.GetUltimate ().owner ().IsModule () &&
323
- symbol.GetUltimate ().owner ().GetName ().value ().ToString () ==
324
- moduleName) {
325
- return true ;
326
- }
327
- return false ;
328
- }
329
-
330
334
std::set<parser::Label> labels_;
331
335
parser::CharBlock currentStatementSourcePosition_;
332
336
SemanticsContext &context_;
0 commit comments