[flang-commits] [flang] 148116a - [flang] Accept a null pointer as a NULL(MOLD=...) actual argument
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Aug 18 15:29:27 PDT 2022
Author: Peter Klausler
Date: 2022-08-18T15:24:10-07:00
New Revision: 148116ab83a69596414cb372070978006e266794
URL: https://github.com/llvm/llvm-project/commit/148116ab83a69596414cb372070978006e266794
DIFF: https://github.com/llvm/llvm-project/commit/148116ab83a69596414cb372070978006e266794.diff
LOG: [flang] Accept a null pointer as a NULL(MOLD=...) actual argument
The MOLD= argument to NULL() is allowed to be a null pointer itself --
for example, NULL(MOLD=NULL(MOLD=...)) should not raise spurious semantic
errors.
Differential Revision: https://reviews.llvm.org/D132166
Added:
Modified:
flang/lib/Evaluate/intrinsics.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 4094a1e671f2..9dbbdc6621ba 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -2084,11 +2084,11 @@ SpecificCall IntrinsicProcTable::Implementation::HandleNull(
if (CheckAndRearrangeArguments(arguments, context.messages(), keywords, 1) &&
arguments[0]) {
if (Expr<SomeType> * mold{arguments[0]->UnwrapExpr()}) {
- bool goodProcPointer{true};
- if (IsAllocatableOrPointer(*mold)) {
+ bool isProcPtrTarget{IsProcedurePointerTarget(*mold)};
+ if (isProcPtrTarget || IsAllocatableOrPointerObject(*mold, context)) {
characteristics::DummyArguments args;
std::optional<characteristics::FunctionResult> fResult;
- if (IsProcedurePointerTarget(*mold)) {
+ if (isProcPtrTarget) {
// MOLD= procedure pointer
const Symbol *last{GetLastSymbol(*mold)};
CHECK(last);
@@ -2101,8 +2101,6 @@ SpecificCall IntrinsicProcTable::Implementation::HandleNull(
args.emplace_back("mold"s,
characteristics::DummyProcedure{common::Clone(*procPointer)});
fResult.emplace(std::move(*procPointer));
- } else {
- goodProcPointer = false;
}
} else if (auto type{mold->GetType()}) {
// MOLD= object pointer
@@ -2115,7 +2113,7 @@ SpecificCall IntrinsicProcTable::Implementation::HandleNull(
context.messages().Say(arguments[0]->sourceLocation(),
"MOLD= argument to NULL() lacks type"_err_en_US);
}
- if (goodProcPointer) {
+ if (fResult) {
fResult->attrs.set(characteristics::FunctionResult::Attr::Pointer);
characteristics::Procedure::Attrs attrs;
attrs.set(characteristics::Procedure::Attr::NullPointer);
More information about the flang-commits
mailing list