Hello Thomas,
sorry for the belated review. I am not completely happy about the
introduction of yet another two global variables, but I also do not see
an easy way out. Hence: OK.
I was playing around with the following test case – you might consider
to add them as well. (I would exclude the error item, however.)
Cheers,
Tobias
! C7110 (R770) If type-spec is omitted, each ac-value expression in the
! array-constructor shall have the same declared type and kind type
parameters
! Should be fine as there is either no or only one ac-value:
print *, [[integer ::],[real::]]
print *, [[integer ::],[real::], [1], [real ::]]
print *, [[integer ::],[real::], ["ABC"], [real ::]] // "ABC"
print *, [integer :: [integer ::],[real::]]
! Old but for completeness:
! OK - accepted
print *, [integer :: [1],[1.0]]
! OK – "Error: Element in INTEGER(4) array constructor at (1) is REAL(4)"
print *, [[1],[1.0]]
end
On 1/2/20 11:35 PM, Thomas Koenig wrote:
The solution is to stash the type away in yet another variable
and only use it if the constructor turns out to be empty, and
the type has not been set some other way.
Regression-tested. OK for trunk?
Save typespec for empty array constructor.
2020-01-02 Thomas Koenig <tkoe...@gcc.gnu.org>
PR fortran/65428
* array.c (empty_constructor): New variable.
(empty_ts): New variable.
(expand_constructor): Save typespec in empty_ts.
Unset empty_constructor if there is an element.
(gfc_expand_constructor): Initialize empty_constructor
and empty_ts. If there was no explicit constructor
type and the constructor is empty, take the type from
empty_ts.
2020-01-02 Thomas Koenig <tkoe...@gcc.gnu.org>
PR fortran/65428
* gfortran.dg/zero_sized_11.f90: New test.