Skip to content

Conversation

@klausler
Copy link
Contributor

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.

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.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Dec 19, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 19, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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 --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;
             }

@klausler klausler merged commit 7453d76 into llvm:main Jan 8, 2025
11 checks passed
@klausler klausler deleted the fix-null branch January 8, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:semantics flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants