aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2005-05-31 17:19:11 +0000
committerPaul Thomas <pault@gcc.gnu.org>2005-05-31 17:19:11 +0000
commit2b052ce2f5a1c84ca9efded4df9308669b9e25e5 (patch)
tree9a856e4a4daa847c9ca97e91ae29830d2728f4b1 /gcc/fortran/trans-array.c
parentd763bb10051498ab4bafe220b644f2aa414de381 (diff)
downloadgcc-2b052ce2f5a1c84ca9efded4df9308669b9e25e5.zip
gcc-2b052ce2f5a1c84ca9efded4df9308669b9e25e5.tar.gz
gcc-2b052ce2f5a1c84ca9efded4df9308669b9e25e5.tar.bz2
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
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 047f8bc..fabbef9 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -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->type = GFC_SS_TEMP;
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. */
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
loop.temp_ss->string_length = NULL;
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)
rse.ss = ss;
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, &lse.pre);