Commit 2b052ce2 by Paul Thomas

re PR fortran/18109 (ICE with explicit array of strings)

2005-05-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/18109
	PR fortran/18283
	PR fortran/19107
	* fortran/trans-array.c (gfc_conv_expr_descriptor): Obtain the
	string length from the expression typespec character length value
	and set temp_ss->stringlength and backend_decl. Obtain the
	tree expression from gfc_conv_expr rather than gfc_conv_expr_val.
	Dereference the expression to obtain the character.
	* fortran/trans-expr.c (gfc_conv_component_ref): Remove the
	dereference of scalar character pointer structure components.
	* fortran/trans-expr.c (gfc_trans_subarray_assign): Obtain the
	string length for the structure component from the component
	expression.

From-SVN: r100400
parent d763bb10
2005-05-31 Paul Thomas <pault@gcc.gnu.org>
PR fortran/18109
PR fortran/18283
PR fortran/19107
* fortran/trans-array.c (gfc_conv_expr_descriptor): Obtain the
string length from the expression typespec character length value
and set temp_ss->stringlength and backend_decl. Obtain the
tree expression from gfc_conv_expr rather than gfc_conv_expr_val.
Dereference the expression to obtain the character.
* fortran/trans-expr.c (gfc_conv_component_ref): Remove the
dereference of scalar character pointer structure components.
* fortran/trans-expr.c (gfc_trans_subarray_assign): Obtain the
string length for the structure component from the component
expression.
2005-05-30 Roger Sayle <roger@eyesopen.com> 2005-05-30 Roger Sayle <roger@eyesopen.com>
* gfortran.h (GFC_STD_LEGACY): New "standard" macro. Reindent. * gfortran.h (GFC_STD_LEGACY): New "standard" macro. Reindent.
......
...@@ -3616,12 +3616,23 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) ...@@ -3616,12 +3616,23 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
loop.temp_ss = gfc_get_ss (); loop.temp_ss = gfc_get_ss ();
loop.temp_ss->type = GFC_SS_TEMP; loop.temp_ss->type = GFC_SS_TEMP;
loop.temp_ss->next = gfc_ss_terminator; loop.temp_ss->next = gfc_ss_terminator;
loop.temp_ss->data.temp.type = gfc_typenode_for_spec (&expr->ts); if (expr->ts.type == BT_CHARACTER)
{
gcc_assert (expr->ts.cl && expr->ts.cl->length
&& expr->ts.cl->length->expr_type == EXPR_CONSTANT);
loop.temp_ss->string_length = gfc_conv_mpz_to_tree
(expr->ts.cl->length->value.integer,
expr->ts.cl->length->ts.kind);
expr->ts.cl->backend_decl = loop.temp_ss->string_length;
}
loop.temp_ss->data.temp.type = gfc_typenode_for_spec (&expr->ts);
/* ... which can hold our string, if present. */ /* ... which can hold our string, if present. */
if (expr->ts.type == BT_CHARACTER) if (expr->ts.type == BT_CHARACTER)
se->string_length = loop.temp_ss->string_length {
= TYPE_SIZE_UNIT (loop.temp_ss->data.temp.type); loop.temp_ss->string_length = TYPE_SIZE_UNIT (loop.temp_ss->data.temp.type);
se->string_length = loop.temp_ss->string_length;
}
else else
loop.temp_ss->string_length = NULL; loop.temp_ss->string_length = NULL;
loop.temp_ss->data.temp.dimen = loop.dimen; loop.temp_ss->data.temp.dimen = loop.dimen;
...@@ -3653,7 +3664,13 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) ...@@ -3653,7 +3664,13 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
rse.ss = ss; rse.ss = ss;
gfc_conv_scalarized_array_ref (&lse, NULL); gfc_conv_scalarized_array_ref (&lse, NULL);
gfc_conv_expr_val (&rse, expr); if (expr->ts.type == BT_CHARACTER)
{
gfc_conv_expr (&rse, expr);
rse.expr = gfc_build_indirect_ref (rse.expr);
}
else
gfc_conv_expr_val (&rse, expr);
gfc_add_block_to_block (&block, &rse.pre); gfc_add_block_to_block (&block, &rse.pre);
gfc_add_block_to_block (&block, &lse.pre); gfc_add_block_to_block (&block, &lse.pre);
......
...@@ -281,7 +281,7 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref) ...@@ -281,7 +281,7 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref)
se->string_length = tmp; se->string_length = tmp;
} }
if (c->pointer && c->dimension == 0) if (c->pointer && c->dimension == 0 && c->ts.type != BT_CHARACTER)
se->expr = gfc_build_indirect_ref (se->expr); se->expr = gfc_build_indirect_ref (se->expr);
} }
...@@ -1671,6 +1671,9 @@ gfc_trans_subarray_assign (tree dest, gfc_component * cm, gfc_expr * expr) ...@@ -1671,6 +1671,9 @@ gfc_trans_subarray_assign (tree dest, gfc_component * cm, gfc_expr * expr)
gfc_start_scalarized_body (&loop, &body); gfc_start_scalarized_body (&loop, &body);
gfc_conv_tmp_array_ref (&lse); gfc_conv_tmp_array_ref (&lse);
if (cm->ts.type == BT_CHARACTER)
lse.string_length = cm->ts.cl->backend_decl;
gfc_conv_expr (&rse, expr); gfc_conv_expr (&rse, expr);
tmp = gfc_trans_scalar_assign (&lse, &rse, cm->ts.type); tmp = gfc_trans_scalar_assign (&lse, &rse, cm->ts.type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment