aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2019-03-27 12:51:43 +0000
committerPaul Thomas <pault@gcc.gnu.org>2019-03-27 12:51:43 +0000
commitd5f48c7c62d3d8cf8982cb29a8128e3b81335d24 (patch)
tree76bbc93eb20c9c454b06f631c411d2415a8c5992 /gcc/fortran/trans-expr.c
parent6461f211e09415edd95315f4f9ff843f4f1d8eff (diff)
downloadgcc-d5f48c7c62d3d8cf8982cb29a8128e3b81335d24.zip
gcc-d5f48c7c62d3d8cf8982cb29a8128e3b81335d24.tar.gz
gcc-d5f48c7c62d3d8cf8982cb29a8128e3b81335d24.tar.bz2
re PR fortran/88247 (ICE in get_array_ctor_var_strlen, at fortran/trans-array.c:2068)
2019-03-27 Paul Thomas <pault@gcc.gnu.org> PR fortran/88247 * expr.c (is_subref_array): Permit substrings to be detected as subref arrays. * trans-array.c (get_array_ctor_var_strlen): Obtain the length of deferred length strings. Handle substrings with a NULL end expression. (trans_array_constructor): Remove an unnecessary blank line. (gfc_conv_scalarized_array_ref): Skip to label 'done' if 'decl' is a pointer array. (get_array_charlen): If the expression is an array, convert the first element of the constructor and use its string length. Get a new charlen if necessary. (gfc_conv_expr_descriptor): Call 'get_array_charlen' for array constructor expressions. If the ss_info string length is available, use that to set the span of character arrays. * trans-expr.c (gfc_get_expr_charlen): Handle substrings * trans-stmt.c (trans_associate_var): Set the pointer array flag for variable targets and constant array constructors. Take care not to reset the string length or the span in the case of expressions that are not converted as direct by reference. 2019-03-27 Paul Thomas <pault@gcc.gnu.org> PR fortran/88247 * gfortran.dg/associate_47.f90: New test. From-SVN: r269962
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 3cd2ffa..19fb16f 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -1824,6 +1824,7 @@ gfc_get_expr_charlen (gfc_expr *e)
{
gfc_ref *r;
tree length;
+ gfc_se se;
gcc_assert (e->expr_type == EXPR_VARIABLE
&& e->ts.type == BT_CHARACTER);
@@ -1859,9 +1860,20 @@ gfc_get_expr_charlen (gfc_expr *e)
/* Do nothing. */
break;
+ case REF_SUBSTRING:
+ gfc_init_se (&se, NULL);
+ gfc_conv_expr_type (&se, r->u.ss.start, gfc_charlen_type_node);
+ length = se.expr;
+ gfc_conv_expr_type (&se, r->u.ss.end, gfc_charlen_type_node);
+ length = fold_build2_loc (input_location, MINUS_EXPR,
+ gfc_charlen_type_node,
+ se.expr, length);
+ length = fold_build2_loc (input_location, PLUS_EXPR,
+ gfc_charlen_type_node, length,
+ gfc_index_one_node);
+ break;
+
default:
- /* We should never got substring references here. These will be
- broken down by the scalarizer. */
gcc_unreachable ();
break;
}