Skip to content

Commit 36ad343

Browse files
authored
[flang] Don't accept NULL() actual for assumed-rank dummy (#71574)
A NULL() pointer without MOLD= cannot be allowed to be associated with an assumed-rank dummy argument, as its rank is not well-defined and neither the RANK() intrinsic function or the SELECT RANK construct will work in the callee.
1 parent 13893a0 commit 36ad343

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

flang/docs/Extensions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ end
9393
non-global name in the same scope. This is not conforming,
9494
but it is useful and unambiguous.
9595
* The argument to `RANDOM_NUMBER` may not be an assumed-size array.
96+
* `NULL()` without `MOLD=` is not allowed to be associated as an
97+
actual argument corresponding to an assumed-rank dummy argument;
98+
its rank in the called procedure would not be well-defined.
9699

97100
## Extensions, deletions, and legacy features supported by default
98101

flang/lib/Semantics/check-call.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,10 @@ static void CheckExplicitInterfaceArg(evaluate::ActualArgument &arg,
10841084
} else if (object.type.type().IsTypelessIntrinsicArgument() &&
10851085
evaluate::IsNullObjectPointer(*expr)) {
10861086
// ok, ASSOCIATED(NULL(without MOLD=))
1087+
} else if (object.type.attrs().test(characteristics::
1088+
TypeAndShape::Attr::AssumedRank)) {
1089+
messages.Say(
1090+
"NULL() without MOLD= must not be associated with an assumed-rank dummy argument"_err_en_US);
10871091
} else if ((object.attrs.test(characteristics::DummyDataObject::
10881092
Attr::Pointer) ||
10891093
object.attrs.test(characteristics::

flang/test/Semantics/call39.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@ subroutine test
2323
call s1(null(a1)) ! ok
2424
call sa(null(a0)) ! ok
2525
call sa(null(a1)) ! ok
26+
!ERROR: NULL() without MOLD= must not be associated with an assumed-rank dummy argument
27+
call sa(null())
28+
!ERROR: NULL() without MOLD= must not be associated with an assumed-rank dummy argument
29+
call sa(null())
2630
end
2731
end

0 commit comments

Comments
 (0)