[flang-commits] [flang] 36ad343 - [flang] Don't accept NULL() actual for assumed-rank dummy (#71574)
via flang-commits
flang-commits at lists.llvm.org
Mon Nov 13 15:14:09 PST 2023
Author: Peter Klausler
Date: 2023-11-13T15:14:05-08:00
New Revision: 36ad3431bbd8ec7dce718b02b35adaf8d9bb8808
URL: https://github.com/llvm/llvm-project/commit/36ad3431bbd8ec7dce718b02b35adaf8d9bb8808
DIFF: https://github.com/llvm/llvm-project/commit/36ad3431bbd8ec7dce718b02b35adaf8d9bb8808.diff
LOG: [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.
Added:
Modified:
flang/docs/Extensions.md
flang/lib/Semantics/check-call.cpp
flang/test/Semantics/call39.f90
Removed:
################################################################################
diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 4e316b0295c82f7..c64a7d53d46ea10 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -93,6 +93,9 @@ end
non-global name in the same scope. This is not conforming,
but it is useful and unambiguous.
* The argument to `RANDOM_NUMBER` may not be an assumed-size array.
+* `NULL()` without `MOLD=` is not allowed to be associated as an
+ actual argument corresponding to an assumed-rank dummy argument;
+ its rank in the called procedure would not be well-defined.
## Extensions, deletions, and legacy features supported by default
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index ced7eec5e6b21e3..47d66ab27cec8f0 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -1084,6 +1084,10 @@ static void CheckExplicitInterfaceArg(evaluate::ActualArgument &arg,
} else if (object.type.type().IsTypelessIntrinsicArgument() &&
evaluate::IsNullObjectPointer(*expr)) {
// ok, ASSOCIATED(NULL(without MOLD=))
+ } else if (object.type.attrs().test(characteristics::
+ TypeAndShape::Attr::AssumedRank)) {
+ messages.Say(
+ "NULL() without MOLD= must not be associated with an assumed-rank dummy argument"_err_en_US);
} else if ((object.attrs.test(characteristics::DummyDataObject::
Attr::Pointer) ||
object.attrs.test(characteristics::
diff --git a/flang/test/Semantics/call39.f90 b/flang/test/Semantics/call39.f90
index 860ab0096401403..41eeba10034786b 100644
--- a/flang/test/Semantics/call39.f90
+++ b/flang/test/Semantics/call39.f90
@@ -23,5 +23,9 @@ subroutine test
call s1(null(a1)) ! ok
call sa(null(a0)) ! ok
call sa(null(a1)) ! ok
+ !ERROR: NULL() without MOLD= must not be associated with an assumed-rank dummy argument
+ call sa(null())
+ !ERROR: NULL() without MOLD= must not be associated with an assumed-rank dummy argument
+ call sa(null())
end
end
More information about the flang-commits
mailing list