[flang] Extend shape analysis to cope with ASSOCIATE construct entities better
authorpeter klausler <pklausler@nvidia.com>
Tue, 10 Mar 2020 23:13:09 +0000 (16:13 -0700)
committerpeter klausler <pklausler@nvidia.com>
Tue, 10 Mar 2020 23:46:25 +0000 (16:46 -0700)
Fix incomplete copy&paste

Another review comment addressed

Original-commit: flang-compiler/f18@a2e2593fa5457a7737faab8ee74e5f3b18cd71f7
Reviewed-on: https://github.com/flang-compiler/f18/pull/1061
Tree-same-pre-rewrite: false

flang/lib/Evaluate/shape.cpp

index c523f30..c0b59cf 100644 (file)
@@ -256,6 +256,13 @@ MaybeExtentExpr GetExtent(
         }
       }
     }
+  } else if (const auto *assoc{
+                 symbol.detailsIf<semantics::AssocEntityDetails>()}) {
+    if (auto shape{GetShape(context, assoc->expr())}) {
+      if (dimension < static_cast<int>(shape->size())) {
+        return std::move(shape->at(dimension));
+      }
+    }
   }
   return std::nullopt;
 }
@@ -316,6 +323,13 @@ MaybeExtentExpr GetUpperBound(
         }
       }
     }
+  } else if (const auto *assoc{
+                 symbol.detailsIf<semantics::AssocEntityDetails>()}) {
+    if (auto shape{GetShape(context, assoc->expr())}) {
+      if (dimension < static_cast<int>(shape->size())) {
+        return std::move(shape->at(dimension));
+      }
+    }
   }
   return std::nullopt;
 }