[flang-commits] [flang] [flang][Lower] Implement lowering for new expression kind used in explicit-shape-bounds-spec (PR #215403)
via flang-commits
flang-commits at lists.llvm.org
Wed Oct 14 01:13:08 PDT 2026
================
@@ -1405,6 +1406,10 @@ void PutBound(llvm::raw_ostream &os, const Bound &x) {
} else if (x.isColon()) {
os << ':';
} else {
+ // A raw ROBE has no Fortran spelling; it may only live in
+ // its own array's ShapeSpec, which PutShape() unwraps whole and never
+ // routes here. Anything else must carry ubound()/lbound() provenance.
+ CHECK(!evaluate::ContainsUntaggedRankOneBoundElement(*x.GetExplicit()));
----------------
MattPD wrote:
Valid code can reach the `ContainsUntaggedRankOneBoundElement` CHECK. The new guard covers three inquiries: `shape`, `size`, and `sizeof`. It does not cover the shape-derived branch of `UBOUND` in `fold-integer.cpp`. That branch handles several forms: an array component, a parenthesized array, or an expression such as `transpose(a)`.
You can reproduce this by saving the following as `t.f90` and running `flang -fsyntax-only t.f90`:
```fortran
module transpose_robe
contains
subroutine s(n, m, c, a, b)
integer, intent(in) :: n(2), m(2)
logical, intent(in) :: c(2)
real :: a(0:merge(n,m,c))
real :: b(ubound(transpose(a),1))
b(1) = 1.0
end subroutine
end module
```
Compiling the source fails at the `ContainsUntaggedRankOneBoundElement` CHECK. The previous PR head 14764c2f accepts the source.
Without `DIM`, as in `b(ubound((a)))`, the writer bypasses the CHECK and writes `%ROBE(...)` into the module file. A later `use` of that module then crashes in the parser.
https://github.com/llvm/llvm-project/pull/215403
More information about the flang-commits
mailing list