[PATCH] PR fortran/102685 - ICE in output_constructor_regular_field, at varasm.c:5514
Harald Anlauf
anlauf@gmx.de
Thu Oct 14 21:27:02 GMT 2021
Dear Fortranners,
the attached patch adds a check for the shape of arrays in derived type
constructors. This brings it in line with other major brands.
Example:
type t
integer :: a(1)
end type
type(t), parameter :: y(2) = t([1,2])
end
This was silently accepted before, but now gives:
pr102685-z1.f90:4:33:
4 | type(t), parameter :: y(2) = t([1,2])
| 1
Error: The shape of component 'a' in the structure constructor at (1) differs from the shape of the declared component for dimension 1 (2/1)
During regtesting several previously invalid testcases surfaced
which would be rejected by the present change. They have been
adjusted along the discussion with Tobias and Paul, see the thread
https://gcc.gnu.org/pipermail/fortran/2021-October/056707.html
In developing the patch I encountered a difficulty with testcase
dec_structure_6.f90, which uses a DEC extension, namelist "old-style
CLIST initializers in STRUCTURE". I could not figure out how to
determine the shape of the initializer; it seemed to be always zero.
I've added code to accept this, but only under -fdec-structure, and
added a TODO in a comment. If somebody reading this could give me
a hint to solve end, I would adjust the patch accordingly.
Regtested on x86_64-pc-linux-gnu. OK? Or further comments?
Thanks,
Harald
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr102685.diff
Type: text/x-patch
Size: 5361 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211014/2aa13a74/attachment.bin>
More information about the Gcc-patches
mailing list