@@ -30,17 +30,20 @@ namespace Fortran::semantics {
30
30
// - any variable from common blocks except
31
31
// - 1-element arrays being single member of COMMON
32
32
// - passed to intrinsic
33
+ // - passed to PURE procedure
33
34
// - avy variable from module except
34
35
// - having attribute PARAMETER or PRIVATE
35
36
// - having DERIVED type
36
37
// - passed to intrinsic
38
+ // - passed to PURE procedure
37
39
// - being arrays having 1-D rank and is not having ALLOCATABLE or POINTER or
38
40
// VOLATILE attributes
39
41
static void CheckPassGlobalVariable (
40
42
const evaluate::Expr<evaluate::SomeType> &actual,
41
43
const parser::ContextualMessages &messages, SemanticsContext &context,
42
44
evaluate::FoldingContext &foldingContext,
43
- const evaluate::SpecificIntrinsic *intrinsic) {
45
+ const evaluate::SpecificIntrinsic *intrinsic,
46
+ const characteristics::Procedure *procedure) {
44
47
const Symbol *actualFirstSymbol{evaluate::GetFirstSymbol (actual)};
45
48
if (actualFirstSymbol) {
46
49
bool warn{false };
@@ -52,6 +55,8 @@ static void CheckPassGlobalVariable(
52
55
ownerName = common->name ().ToString ();
53
56
if (intrinsic) {
54
57
warn |= false ;
58
+ } else if (procedure && procedure->IsPure ()) {
59
+ warn |= false ;
55
60
} else if (!(actualFirstSymbol->Rank () == 1 &&
56
61
actualFirstSymbol->offset () == 0 )) {
57
62
warn |= true ;
@@ -86,6 +91,8 @@ static void CheckPassGlobalVariable(
86
91
warn |= false ;
87
92
} else if (intrinsic) {
88
93
warn |= false ;
94
+ } else if (procedure && procedure->IsPure ()) {
95
+ warn |= false ;
89
96
} else if (actualFirstSymbol->Rank () != 1 ) {
90
97
warn |= true ;
91
98
} else if (!actualFirstSymbol->attrs ().test (Attr::ALLOCATABLE) &&
@@ -209,7 +216,7 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
209
216
210
217
if (const auto *expr{arg.UnwrapExpr ()}) {
211
218
CheckPassGlobalVariable (*expr, messages, context, foldingContext,
212
- /* intrinsic=*/ nullptr );
219
+ /* intrinsic=*/ nullptr , /* procedure= */ nullptr );
213
220
}
214
221
}
215
222
@@ -1247,7 +1254,8 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
1247
1254
" %VAL argument must be a scalar numeric or logical expression" _err_en_US);
1248
1255
}
1249
1256
1250
- CheckPassGlobalVariable (actual, messages, context, foldingContext, intrinsic);
1257
+ CheckPassGlobalVariable (
1258
+ actual, messages, context, foldingContext, intrinsic, &procedure);
1251
1259
}
1252
1260
1253
1261
static void CheckProcedureArg (evaluate::ActualArgument &arg,
0 commit comments