[flang-commits] [flang] [flang][semantic] Implement semantic checks and new data structure (PR #203030)
via flang-commits
flang-commits at lists.llvm.org
Wed Jul 1 08:02:05 PDT 2026
================
@@ -343,11 +350,138 @@ void ArraySpecAnalyzer::Analyze(const parser::ExplicitShapeSpec &x) {
std::get<parser::SpecificationExpr>(x.t));
}
+std::optional<ArraySpecAnalyzer::ExplicitShapeBoundsResult>
+ArraySpecAnalyzer::checkExplicitShapeBoundsSpec(
+ const parser::ExplicitShapeBoundsSpec &x) {
+ const auto &lowerBoundOpt{std::get<0>(x.t)};
+ const auto &upperBound{std::get<1>(x.t)};
+
+ // Analyze, validate, fold, and wrap one bound expression in a Bound.
+ // Returns the Bound and, for rank-1, the constant extent; for scalar
+ // the extent is 0 (meaning "broadcast").
+ bool hasError{false};
+ auto analyzeBound =
+ [&](const auto &parseBound,
+ bool isUpper) -> std::optional<std::pair<Bound, std::int64_t>> {
+ MaybeExpr expr{AnalyzeExpr(context_, parseBound.thing)};
----------------
ivanrodriguez3753 wrote:
I had a check and deleted it, though I can put it back in. My reasoning is that the expression was already analyzed as part of the rewrite from std::list<ExplicitShapeSpec> to ExplicitShapeBoundsSpec, so it's not possible for it to return std::nullopt otherwise the rewrite never would have happened in the first place. Thoughts?
https://github.com/llvm/llvm-project/pull/203030
More information about the flang-commits
mailing list