[flang-commits] [flang] [flang] Suppress error meant to prevent discontiguous association whe… (PR #73175)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Nov 22 13:52:13 PST 2023


https://github.com/klausler created https://github.com/llvm/llvm-project/pull/73175

…n actual argument is contiguous

When an element of a contiguous pointer array or assumed-shape array is associated as an actual argument with an assumed-size dummy array, don't flag the usage as an error.

>From 7093e1f43ce970dd4b2c5405db7cc293ba4b9b36 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Wed, 22 Nov 2023 13:48:23 -0800
Subject: [PATCH] [flang] Suppress error meant to prevent discontiguous
 association when actual argument is contiguous

When an element of a contiguous pointer array or assumed-shape array is
associated as an actual argument with an assumed-size dummy array,
don't flag the usage as an error.
---
 flang/lib/Semantics/check-call.cpp | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index efc2cb0a291ddce..b7829362f315ee4 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -529,17 +529,18 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
               dummyName);
         }
         if (actualIsArrayElement && actualLastSymbol &&
-            IsPointer(*actualLastSymbol)) {
-          basicError = true;
-          messages.Say(
-              "Element of pointer array may not be associated with a %s array"_err_en_US,
-              dummyName);
-        }
-        if (actualLastSymbol && IsAssumedShape(*actualLastSymbol)) {
-          basicError = true;
-          messages.Say(
-              "Element of assumed-shape array may not be associated with a %s array"_err_en_US,
-              dummyName);
+            !evaluate::IsContiguous(*actualLastSymbol, foldingContext)) {
+          if (IsPointer(*actualLastSymbol)) {
+            basicError = true;
+            messages.Say(
+                "Element of pointer array may not be associated with a %s array"_err_en_US,
+                dummyName);
+          } else if (IsAssumedShape(*actualLastSymbol)) {
+            basicError = true;
+            messages.Say(
+                "Element of assumed-shape array may not be associated with a %s array"_err_en_US,
+                dummyName);
+          }
         }
       }
     }



More information about the flang-commits mailing list