[flang-commits] [flang] 2414a90 - [flang] Catch NULL(MOLD=assumed-rank) (#95270)
via flang-commits
flang-commits at lists.llvm.org
Thu Jun 13 10:57:11 PDT 2024
Author: Peter Klausler
Date: 2024-06-13T10:57:06-07:00
New Revision: 2414a90730d87c20d9ff8d7951ed24e3328124ed
URL: https://github.com/llvm/llvm-project/commit/2414a90730d87c20d9ff8d7951ed24e3328124ed
DIFF: https://github.com/llvm/llvm-project/commit/2414a90730d87c20d9ff8d7951ed24e3328124ed.diff
LOG: [flang] Catch NULL(MOLD=assumed-rank) (#95270)
An assumed-rank dummy argument is not an acceptable MOLD argument to
NULL(), whose result must have a known rank at compilation time.
Added:
Modified:
flang/lib/Evaluate/intrinsics.cpp
flang/test/Semantics/null01.f90
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 58c1b6989f495..ace316174a892 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -2691,6 +2691,10 @@ SpecificCall IntrinsicProcTable::Implementation::HandleNull(
mold = nullptr;
}
if (mold) {
+ if (IsAssumedRank(*arguments[0])) {
+ context.messages().Say(arguments[0]->sourceLocation(),
+ "MOLD= argument to NULL() must not be assumed-rank"_err_en_US);
+ }
bool isProcPtrTarget{
IsProcedurePointerTarget(*mold) && !IsNullObjectPointer(*mold)};
if (isProcPtrTarget || IsAllocatableOrPointerObject(*mold)) {
diff --git a/flang/test/Semantics/null01.f90 b/flang/test/Semantics/null01.f90
index 3bf620048e2f2..04d94865356b0 100644
--- a/flang/test/Semantics/null01.f90
+++ b/flang/test/Semantics/null01.f90
@@ -151,10 +151,16 @@ subroutine s1(x)
subroutine s2(x)
type(pdt(*)), pointer, intent(in) :: x
end
- subroutine test
+ subroutine s3(ar)
+ real, pointer :: ar(..)
+ end
+ subroutine test(ar)
+ real, pointer :: ar(..)
!ERROR: Actual argument associated with dummy argument 'x=' is a NULL() pointer without a MOLD= to provide a character length
call s1(null())
!ERROR: Actual argument associated with dummy argument 'x=' is a NULL() pointer without a MOLD= to provide a value for the assumed type parameter 'n'
call s2(null())
+ !ERROR: MOLD= argument to NULL() must not be assumed-rank
+ call s3(null(ar))
end
end
More information about the flang-commits
mailing list