[flang-commits] [flang] [flang] Silence inappropriate error message (PR #120614)

via flang-commits flang-commits at lists.llvm.org
Thu Dec 19 10:04:06 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

A recent patch added better compatibility checking for actual procedure arguments, but it has led to a few failures in the Fujitsu Fortran test suite in cases of NULL() actual arguments being associated with dummy procedure pointers.  As is the case with dummy data pointers, these must always be accepted.

Fixes Fujitsu Fortran test cases 0249_0023 through 0028 and 0387_0047.

---
Full diff: https://github.com/llvm/llvm-project/pull/120614.diff


1 Files Affected:

- (modified) flang/lib/Semantics/expression.cpp (+9) 


``````````diff
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index c2eb17c1ac8e5b..4a986cb51b1b11 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -2536,6 +2536,15 @@ static bool CheckCompatibleArgument(bool isElemental,
             return false;
           },
           [&](const characteristics::DummyProcedure &dummy) {
+            if ((dummy.attrs.test(
+                     characteristics::DummyProcedure::Attr::Optional) ||
+                    dummy.attrs.test(
+                        characteristics::DummyProcedure::Attr::Pointer)) &&
+                IsBareNullPointer(expr)) {
+              // NULL() is compatible with any dummy pointer
+              // or optional dummy procedure.
+              return true;
+            }
             if (!expr || !IsProcedurePointerTarget(*expr)) {
               return false;
             }

``````````

</details>


https://github.com/llvm/llvm-project/pull/120614


More information about the flang-commits mailing list