[flang-commits] [flang] [flang] Add parser support for explicit-shape-bounds-spec (PR #188447)

via flang-commits flang-commits at lists.llvm.org
Mon Apr 20 12:46:08 PDT 2026


================
@@ -237,7 +238,67 @@ ArraySpec ArraySpecAnalyzer::Analyze(const parser::ComponentArraySpec &x) {
   CHECK(!arraySpec_.empty());
   return arraySpec_;
 }
+
+static bool shouldRewriteShapeSpecListToExplicitBounds(
+    SemanticsContext &context, const parser::ArraySpec &x) {
+  auto &explicitShapeSpecList{std::get<std::list<parser::ExplicitShapeSpec>>(
+      const_cast<parser::ArraySpec &>(x).u)};
+
+  if (explicitShapeSpecList.size() != 1) {
+    return false;
+  }
+
+  auto &explicitShapeSpec{explicitShapeSpecList.front()};
+  const auto &upperBound{std::get<1>(explicitShapeSpec.t)};
+  const auto &lowerBoundOpt{std::get<0>(explicitShapeSpec.t)};
+
+  bool foundArray{false};
+
+  if (MaybeExpr analyzedExpr =
+          AnalyzeExpr(context, upperBound.v.thing.thing.value());
----------------
ivanrodriguez3753 wrote:

Sure. I've changed the code to use parser::UnwrapRef<parser::Expr> in this function shouldRewriteShapeSpecListToExplicitBounds. I cannot avoid the use of .thing in rewriteShapeSpecListToExplicitBounds because the rewrite needs the correct level of indirection. That is, the new node kind ExplicitShapeBoundsSpec expects an IntExpr (or rather a tuple of them).

https://github.com/llvm/llvm-project/pull/188447


More information about the flang-commits mailing list