diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2018-09-18 17:58:20 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2018-09-18 17:58:20 +0000 |
commit | e8db6cd5fb1ad254329e426dcc8e958c02e2284f (patch) | |
tree | 84a19f10fa7f398d30f138a265286552df4b586e /gcc/fortran/trans-array.c | |
parent | b819cc44a1a8f0b47f2c9c421980126776d9a8bb (diff) | |
download | gcc-e8db6cd5fb1ad254329e426dcc8e958c02e2284f.zip gcc-e8db6cd5fb1ad254329e426dcc8e958c02e2284f.tar.gz gcc-e8db6cd5fb1ad254329e426dcc8e958c02e2284f.tar.bz2 |
re PR fortran/87336 (wrong output for pointer dummy assiocated to target actual argument)
2018-09-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/87336
* trans-array.c (gfc_get_array_span): Try to get the element
length of incomplete types. Return NULL_TREE otherwise.
(gfc_conv_expr_descriptor): Only set the 'span' field if the
above does not return NULL_TREE. Set 'span' field if possible
for all new descriptors.
2018-09-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/87336
* gfortran.dg/pointer_array_10.f90 : New test.
* gfortran.dg/assign_10.f90 : Increase 'parm' count to 20.
* gfortran.dg/transpose_optimization_2.f90 : Increase 'parm'
count to 72.
From-SVN: r264405
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 9565b7d..95ea615 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -849,10 +849,22 @@ gfc_get_array_span (tree desc, gfc_expr *expr) else { /* If none of the fancy stuff works, the span is the element - size of the array. */ + size of the array. Attempt to deal with unbounded character + types if possible. Otherwise, return NULL_TREE. */ tmp = gfc_get_element_type (TREE_TYPE (desc)); - tmp = fold_convert (gfc_array_index_type, - size_in_bytes (tmp)); + if (tmp && TREE_CODE (tmp) == ARRAY_TYPE + && TYPE_MAX_VALUE (TYPE_DOMAIN (tmp)) == NULL_TREE) + { + if (expr->expr_type == EXPR_VARIABLE + && expr->ts.type == BT_CHARACTER) + tmp = fold_convert (gfc_array_index_type, + gfc_get_expr_charlen (expr)); + else + tmp = NULL_TREE; + } + else + tmp = fold_convert (gfc_array_index_type, + size_in_bytes (tmp)); } return tmp; } @@ -7074,7 +7086,8 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) /* ....and set the span field. */ tmp = gfc_get_array_span (desc, expr); - gfc_conv_descriptor_span_set (&se->pre, se->expr, tmp); + if (tmp != NULL_TREE) + gfc_conv_descriptor_span_set (&se->pre, se->expr, tmp); } else if (se->want_pointer) { @@ -7344,13 +7357,9 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) desc = info->descriptor; if (se->direct_byref && !se->byref_noassign) { - /* For pointer assignments we fill in the destination.... */ + /* For pointer assignments we fill in the destination. */ parm = se->expr; parmtype = TREE_TYPE (parm); - - /* ....and set the span field. */ - tmp = gfc_get_array_span (desc, expr); - gfc_conv_descriptor_span_set (&loop.pre, parm, tmp); } else { @@ -7388,6 +7397,11 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) } } + /* Set the span field. */ + tmp = gfc_get_array_span (desc, expr); + if (tmp != NULL_TREE) + gfc_conv_descriptor_span_set (&loop.pre, parm, tmp); + offset = gfc_index_zero_node; /* The following can be somewhat confusing. We have two |