[Patch, fortran] PR31879 , PR31197 , PR31258 & PR32703 - various character problems

Paul Thomas paulthomas2@wanadoo.fr
Thu Aug 30 21:37:00 GMT 2007


Dear All,

Thank you for all the help on this one.  I attach an updated/corrected 
patch.

It should be noted that, although PR32703 is fixed, the code that is 
generated is not correct.  Try:

program array_char
implicit none
character (len=2) :: x, y
x = "a "
y = "cd"
print*,[trim(x),trim(y)]
end program array_char

This is so different that I propose to close out PR32703, when the patch 
is committed, and to submit a new PR for this bug.

I added a testcase for the fix of the cp2k regression.

Regtested on Cygwin_NT/amd64 and declared cp2k proof by Tobias - OK for 
trunk?

Paul

2007-08-30  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/31879
    PR fortran/31197
    PR fortran/31258
    PR fortran/32703
    * gfortran.h : Add prototype for gfc_resolve_substring_charlen.
    * resolve.c (gfc_resolve_substring_charlen): New function.
    (resolve_ref): Call gfc_resolve_substring_charlen.
    (gfc_resolve_character_operator): New function.
    (gfc_resolve_expr): Call the new functions in cases where the
    character length is missing.
    * iresolve.c (cshift, eoshift, merge, pack, reshape, spread,
    transpose, unpack): Call gfc_resolve_substring_charlen for
    source expressions that are character and have a reference.
    * trans.h (gfc_trans_init_string_length) Change name to
    gfc_conv_string_length; modify references in trans-expr.c,
    trans-array.c and trans-decl.c.
    * trans-expr.c (gfc_trans_string_length): Handle case of no
    backend_decl.
    (gfc_conv_aliased_arg): Remove code for treating substrings
    and replace with call to gfc_trans_string_length.
    * trans-array.c (gfc_conv_expr_descriptor): Remove code for
    treating strings and call gfc_trans_string_length instead.

2007-08-30  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/31879
    * gfortran.dg/char_length_7.f90: New test.
    * gfortran.dg/char_length_9.f90: New test.
    * gfortran.dg/char_assign_1.f90: Add extra warning.

    PR fortran/31197
    PR fortran/31258
    * gfortran.dg/char_length_8.f90: New test.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit_plus.diff
Type: text/x-patch
Size: 26546 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070830/b3b596e0/attachment.bin>


More information about the Fortran mailing list