This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch,fortran] PR31608 again - wrong types in character array/scalar binop


:ADDPATCH fortran:

I have been guilty of not reading the instructions on the box again.
Whilst I fixed one version of the bug, the original remained
untouched.

The problem is associated with character descriptor arrays, where the
data field has been cast as the likes of (*(char[0:][1:1] *)
atmp.0.data.  This grunges up gfc_trans_scalar_assign, in the call
from gfc_conv_expr_descriptor, and so is passed over to
gfc_add_modify_expr. There, the particular case of associating a
char[1:1] with a char is not handled correctly and types are mixed;
eg.

          {
            char char.6;

            char.6 = (*(char[0:][1:1] *) atmp.0.data)[S.5][1]{lb: 1
sz: 1} + 224;
            (*(char[0:][1:1] *) atmp.4.data)[S.5] =
*(_gfortran_compare_string (D.1384, &(*(char[0:][1:1] *)
atmp.2.data)[S.5], 1, "a") >= 0 && _gfortran_compare_string (D.1393,
&(*(char[0:][1:1] *) atmp.3.data)[S.5], 1, "z") <= 0 ? &char.6 :
&(*(char[0:][1:1] *) atmp.1.data)[S.5]);
          }
          S.5 = S.5 + 1;
        }

First the lvalue in the second assignment is not the first element of
the 1:1 array and second, the same kind of beast is mixed with a
humble 'char' in the then/else branches of the condition.  The patch
upgrades the (*(char[0:][1:1] *) atmp.0.data)[S.5] references to
(*(char[0:][1:1] *) atmp.0.data)[S.5][1]{lb: 1 sz: 1}.

Regtested on Cygwin_NT and to be put through the mill tonight on x86_ia64/FC5.

OK for trunk?

Paul

2007-11-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31608
	* trans-array.c (gfc_conv_expr_descriptor): Remove exception
	for indirect references in the call to gfc_trans_scalar_assign.
	* trans-expr.c (gfc_conv_string_parameter): Instead of asserting
	that the expression is not an indirect reference, cast it to a
	pointer type of the length given by se->string_length.

2007-11-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31608
	* gfortran.dg/char_cast_2.f90: New test based on achar_4.f90.


-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

Attachment: submit2.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]