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] PR15809 (PR19276) - ICE and segfault with automa tic character, dummy pointer arrays


:ADDPATCH fortran:

This patch fixes PR15809 and the problem that Toon notified to the list last
night. This is the last of the unfixed problems in the character meta-bug
PR19276 (I note that I have not committed the other two fixes to gcc-4.1; I
will do so in the next 24hours.)

There are three elements:

1] The fix to the problem that Toon notified is in trans-io.c; around the
gcc-assert that caused the ICE.  The problem is that 

tmp = gfc_get_dtype (TREE_TYPE (se.expr));
if (((TREE_INT_CST_LOW (tmp) & GFC_DTYPE_TYPE_MASK) 
        >> GFC_DTYPE_TYPE_SHIFT) != GFC_DTYPE_DERIVED)

is not compatible with the case, where the dtype is an expression.  This,
slightly unusual situation occurs with automatic character length arrays.
The solution is to use the references in the gfc_expr to generate the
condition.  This has the advantage that a descriptor is not generated, so
that no clean-up is necessary for the cases in which a descriptor cannot be
passed.

2] The second element is the incomplete PR15809 fix proposed by Erik
Edelmann that allows both VAR_DECLs and PARM_DECLs to go through
trans-array.c(gfc_trans_deferred_array ).  This stops the ICEs on references
to the offending variables that do not need any size information.

3] The final bit of the puzzle is to attach the character length onto the
dtype. This has been done by setting the TYPE_SIZE_UNIT of the array
elements in trans-decl.c(gfc_get_symbol_decl). This works because the
evaluation of the expression for the dtype occurs in the function code.
Leaving this step until gfc_trans_deferred_array does work correctly, as far
as I could assertain, but leaves some alarming dtype assignements that do
not contain a size.

Regtested on trunk/Cygwin-i686.  OK for 4.*?

Please excuse me for not using contextual diffs. The patches are simple
enough that this should not be a problem.

Paul T




Attachment: pr15809.txt
Description: Text document


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