@@ -29,15 +29,18 @@ namespace Fortran::semantics {
29
29
// Raise warnings for some dangerous context of passing global variables
30
30
// - any variable from common blocks except
31
31
// - 1-element arrays being single member of COMMON
32
+ // - passed to intrinsic
32
33
// - avy variable from module except
33
34
// - having attribute PARAMETER or PRIVATE
34
35
// - having DERIVED type
36
+ // - passed to intrinsic
35
37
// - being arrays having 1-D rank and is not having ALLOCATABLE or POINTER or
36
38
// VOLATILE attributes
37
39
static void CheckPassGlobalVariable (
38
40
const evaluate::Expr<evaluate::SomeType> &actual,
39
41
const parser::ContextualMessages &messages, SemanticsContext &context,
40
- evaluate::FoldingContext &foldingContext) {
42
+ evaluate::FoldingContext &foldingContext,
43
+ const evaluate::SpecificIntrinsic *intrinsic) {
41
44
const Symbol *actualFirstSymbol{evaluate::GetFirstSymbol (actual)};
42
45
if (actualFirstSymbol) {
43
46
bool warn{false };
@@ -47,7 +50,9 @@ static void CheckPassGlobalVariable(
47
50
const Symbol *common{FindCommonBlockContaining (*actualFirstSymbol)};
48
51
ownerType = " COMMON" ;
49
52
ownerName = common->name ().ToString ();
50
- if (!(actualFirstSymbol->Rank () == 1 &&
53
+ if (intrinsic) {
54
+ warn |= false ;
55
+ } else if (!(actualFirstSymbol->Rank () == 1 &&
51
56
actualFirstSymbol->offset () == 0 )) {
52
57
warn |= true ;
53
58
} else if (actualFirstSymbol->Rank () == 1 ) {
@@ -79,6 +84,8 @@ static void CheckPassGlobalVariable(
79
84
actualFirstSymbol, foldingContext)};
80
85
type->type ().category () == TypeCategory::Derived) {
81
86
warn |= false ;
87
+ } else if (intrinsic) {
88
+ warn |= false ;
82
89
} else if (actualFirstSymbol->Rank () != 1 ) {
83
90
warn |= true ;
84
91
} else if (!actualFirstSymbol->attrs ().test (Attr::ALLOCATABLE) &&
@@ -201,7 +208,8 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
201
208
}
202
209
203
210
if (const auto *expr{arg.UnwrapExpr ()}) {
204
- CheckPassGlobalVariable (*expr, messages, context, foldingContext);
211
+ CheckPassGlobalVariable (*expr, messages, context, foldingContext,
212
+ /* intrinsic=*/ nullptr );
205
213
}
206
214
}
207
215
@@ -1239,7 +1247,7 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
1239
1247
" %VAL argument must be a scalar numeric or logical expression" _err_en_US);
1240
1248
}
1241
1249
1242
- CheckPassGlobalVariable (actual, messages, context, foldingContext);
1250
+ CheckPassGlobalVariable (actual, messages, context, foldingContext, intrinsic );
1243
1251
}
1244
1252
1245
1253
static void CheckProcedureArg (evaluate::ActualArgument &arg,
0 commit comments