A section of a parameter array may be non-contiguous,
so the current !IsVariable(expr) check is too optimistic
to claim contiguity.
This patch fixes issues with incorrect hlfir.designate op generated
during lowering: the lowering queries IsContiguous to decide whether
to use fir.box<fir.array> or plain fir.ref<fir.array> to represent
the designator result.
You don't need to use GetPtrFromOptional here, just use a & reference: if (const auto &lb{baseLbounds->at(j)}) { ... }. Same with the upper bound.