[flang-commits] [PATCH] D123727: [flang] Fix Symbol::Rank for ProcEntityDetails

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Apr 15 09:55:05 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGca2be81e34a6: [flang] Fix Symbol::Rank for ProcEntityDetails (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123727/new/

https://reviews.llvm.org/D123727

Files:
  flang/include/flang/Semantics/symbol.h
  flang/lib/Evaluate/shape.cpp
  flang/test/Evaluate/rewrite01.f90


Index: flang/test/Evaluate/rewrite01.f90
===================================================================
--- flang/test/Evaluate/rewrite01.f90
+++ flang/test/Evaluate/rewrite01.f90
@@ -57,6 +57,13 @@
 end subroutine
 
 subroutine shape_test(x, n, m)
+  abstract interface
+    function foo(n)
+      integer, intent(in) :: n
+      real, pointer :: foo(:,:)
+    end function
+  end interface
+  procedure(foo), pointer :: pf
   integer :: x(n, m)
   !CHECK: PRINT *, [INTEGER(4)::int(size(x,dim=1,kind=8),kind=4),int(size(x,dim=2,kind=8),kind=4)]
   print *, shape(x)
@@ -66,6 +73,8 @@
   print *, shape(returns_array_2(m))
   !CHECK: PRINT *, [INTEGER(8)::42_8]
   print *, shape(returns_array_3(), kind=8)
+  !CHECK: PRINT *, 2_4
+  print *, rank(pf(1))
 end subroutine
 
 subroutine lbound_test(x, n, m)
Index: flang/lib/Evaluate/shape.cpp
===================================================================
--- flang/lib/Evaluate/shape.cpp
+++ flang/lib/Evaluate/shape.cpp
@@ -690,9 +690,9 @@
                 // to symbols that belong to the subroutine scope and are
                 // meaningless on the caller side without the related call
                 // expression.
-                for (auto extent : *resultShape) {
-                  if (extent && !IsConstantExpr(*extent)) {
-                    return std::nullopt;
+                for (auto &extent : *resultShape) {
+                  if (extent && !IsActuallyConstant(*extent)) {
+                    extent.reset();
                   }
                 }
               }
Index: flang/include/flang/Semantics/symbol.h
===================================================================
--- flang/include/flang/Semantics/symbol.h
+++ flang/include/flang/Semantics/symbol.h
@@ -639,6 +639,10 @@
             [](const UseDetails &x) { return x.symbol().Rank(); },
             [](const HostAssocDetails &x) { return x.symbol().Rank(); },
             [](const ObjectEntityDetails &oed) { return oed.shape().Rank(); },
+            [](const ProcEntityDetails &ped) {
+              const Symbol *iface{ped.interface().symbol()};
+              return iface ? iface->Rank() : 0;
+            },
             [](const AssocEntityDetails &aed) {
               if (const auto &expr{aed.expr()}) {
                 if (auto assocRank{aed.rank()}) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123727.423125.patch
Type: text/x-patch
Size: 2321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220415/24edd160/attachment-0001.bin>


More information about the flang-commits mailing list