There were two problems with constant arrays whose lower bound is not 1.
First, when folding the arrays, we were creating the folded array to have lower
bounds of 1 but not re-adjusting their lower bounds to the declared values.
Second, we were not calculating the extents correctly. Both of these problems
led to bogus error messages.
I fixed the first problem by adjusting the lower bounds in
NonPointerInitializationExpr() in Evaluate/check-expression.cpp. I found an
existing class and method that did exactly what was needed that was originally
designed to expand a scalar value into an array called ScalarConstantExpander.
I renamed this class to reflect its generalization to ArrayConstantMaker.
I fixed the second problem by changing the formula that calculates upper bounds
in in the function ComputeUpperBound() in Evaluate/shape.cpp.
I added tests that trigger the bogus error messages mentioned above along with
a constant folding tests that uses array operands with shapes that conform but
have different bounds.
Since lbounds has to be a non-empty optional, why make it optional at all? I.e. why not declare it as ConstantSubscripts &&lbounds?