Skip to content

Commit b0dc77f

Browse files
committed
Allow passing to VALUE dummy argument
1 parent d0547e4 commit b0dc77f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

flang/lib/Semantics/check-call.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,21 @@ namespace Fortran::semantics {
3131
// - 1-element arrays being single member of COMMON
3232
// - passed to intrinsic
3333
// - passed to PURE procedure
34+
// - passed to VALUE dummy argument
3435
// - avy variable from module except
3536
// - having attribute PARAMETER or PRIVATE
3637
// - having DERIVED type
3738
// - passed to intrinsic
3839
// - passed to PURE procedure
40+
// - passed to VALUE dummy argument
3941
// - being arrays having 1-D rank and is not having ALLOCATABLE or POINTER or
4042
// VOLATILE attributes
4143
static void CheckPassGlobalVariable(
4244
const evaluate::Expr<evaluate::SomeType> &actual,
4345
const parser::ContextualMessages &messages, SemanticsContext &context,
4446
evaluate::FoldingContext &foldingContext,
4547
const evaluate::SpecificIntrinsic *intrinsic,
46-
const characteristics::Procedure *procedure) {
48+
const characteristics::Procedure *procedure, bool dummyIsValue = false) {
4749
const Symbol *actualFirstSymbol{evaluate::GetFirstSymbol(actual)};
4850
if (actualFirstSymbol) {
4951
bool warn{false};
@@ -57,6 +59,8 @@ static void CheckPassGlobalVariable(
5759
warn |= false;
5860
} else if (procedure && procedure->IsPure()) {
5961
warn |= false;
62+
} else if (dummyIsValue) {
63+
warn |= false;
6064
} else if (!(actualFirstSymbol->Rank() == 1 &&
6165
actualFirstSymbol->offset() == 0)) {
6266
warn |= true;
@@ -93,6 +97,8 @@ static void CheckPassGlobalVariable(
9397
warn |= false;
9498
} else if (procedure && procedure->IsPure()) {
9599
warn |= false;
100+
} else if (dummyIsValue) {
101+
warn |= false;
96102
} else if (actualFirstSymbol->Rank() != 1) {
97103
warn |= true;
98104
} else if (!actualFirstSymbol->attrs().test(Attr::ALLOCATABLE) &&
@@ -1254,8 +1260,8 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
12541260
"%VAL argument must be a scalar numeric or logical expression"_err_en_US);
12551261
}
12561262

1257-
CheckPassGlobalVariable(
1258-
actual, messages, context, foldingContext, intrinsic, &procedure);
1263+
CheckPassGlobalVariable(actual, messages, context, foldingContext, intrinsic,
1264+
&procedure, dummyIsValue);
12591265
}
12601266

12611267
static void CheckProcedureArg(evaluate::ActualArgument &arg,

0 commit comments

Comments
 (0)