[flang-commits] [PATCH] D129670: [flang] Better dummy procedure dummy argument compatibility checking

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Jul 13 11:28:52 PDT 2022


klausler created this revision.
klausler added a reviewer: jeanPerier.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

When comparing characteristics of dummy arguments to dummy procedures
for compatibility, ignore extent expressions in shapes that are
dummy argument descriptor inquiries -- they will necessarily refer
to distinct dummy argument symbols and return a false incompatibility
result.  For example, in:

  module m
   contains
    subroutine bar(s)
      interface
         subroutine s(g)
           integer, intent(in) :: g(:)
         end subroutine s
      end interface
    end subroutine bar
    subroutine t(v)
      integer, intent(in) :: v(:)
    end subroutine t
    subroutine foo
      call bar(t)
    end subroutine foo
  end module

the actual procedure argument "t" is compatible with the dummy procedure
argument "s" of "bar", because the ranks of t's dummy data object argument
"v" and s's argument "g" match, and their extents are both assumed.

Fixes https://github.com/llvm/llvm-project/issues/55779.


https://reviews.llvm.org/D129670

Files:
  flang/lib/Evaluate/characteristics.cpp


Index: flang/lib/Evaluate/characteristics.cpp
===================================================================
--- flang/lib/Evaluate/characteristics.cpp
+++ flang/lib/Evaluate/characteristics.cpp
@@ -257,8 +257,14 @@
       coshape == that.coshape;
 }
 
+static bool AreCompatibleDummyDataObjectShapes(const Shape &x, const Shape &y) {
+  // TODO: Validate more than just compatible ranks
+  return GetRank(x) == GetRank(y);
+}
+
 bool DummyDataObject::IsCompatibleWith(const DummyDataObject &actual) const {
-  return type.shape() == actual.type.shape() &&
+  return AreCompatibleDummyDataObjectShapes(
+             type.shape(), actual.type.shape()) &&
       type.type().IsTkCompatibleWith(actual.type.type()) &&
       attrs == actual.attrs && intent == actual.intent &&
       coshape == actual.coshape;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129670.444347.patch
Type: text/x-patch
Size: 814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220713/caa69e16/attachment.bin>


More information about the flang-commits mailing list