[Patch, fortran] PRs 96100 and 96101 - Problems with string lengths of array constructors

Paul Richard Thomas paul.richard.thomas@gmail.com
Thu Aug 13 15:29:49 GMT 2020


Hi All,

The fix for PR9601 is rather trivial and is the last chunk of the patch.
Finding the fix for PR96100 took a silly amount of time but it now looks
rather obvious. Trying to evaluate the string length by calling
gfc_conv_expr_descriptor, when this function is already failing to find it
is kind of doomed to failure :-) Therefore, gfc_conv_expr is used with
tse.descriptor_only set. This has the effect of ignoring trailing array
references and making use of gfc_conv_component_ref's being able to extract
the hidden string length for deferred length components. Finally, the
string length of the first element in the array constructor is set if this
is a deferred length component.

Regtests OK on FC31/x86_64 - OK for master?

Paul

This patch fixes PR96100 and PR96101 by making some minor changes to
the evaluation of string lengths for gfc_conv_expr_descriptor.

2020-08-13  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/96100
PR fortran/96101
* trans-array.c (get_array_charlen): Tidy up the evaluation of
the string length for array constructors. Avoid trailing array
references. Ensure string lengths of deferred length components
are set. For parentheses operator apply string  length to both
the primary expression and the enclosed expression.

gcc/testsuite/
PR fortran/96100
PR fortran/96101
* gfortran.dg/char_length_23.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: text/x-patch
Size: 1665 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200813/54344839/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: char_length_23.f90
Type: text/x-fortran
Size: 485 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200813/54344839/attachment-0003.bin>


More information about the Gcc-patches mailing list