aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 2ea978d..c872889 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -5472,6 +5472,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, bool g77,
bool this_array_result;
bool contiguous;
bool no_pack;
+ bool array_constructor;
+ bool good_allocatable;
gfc_symbol *sym;
stmtblock_t block;
gfc_ref *ref;
@@ -5513,7 +5515,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, bool g77,
if (sym->ts.type == BT_CHARACTER)
se->string_length = sym->ts.u.cl->backend_decl;
- if (sym->ts.type == BT_DERIVED && !sym->as)
+ if (sym->ts.type == BT_DERIVED)
{
gfc_conv_expr_descriptor (se, expr, ss);
se->expr = gfc_conv_array_data (se->expr);
@@ -5550,8 +5552,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, bool g77,
}
}
- /* There is no need to pack and unpack the array, if it is an array
- constructor or contiguous and not deferred or assumed shape. */
+ /* There is no need to pack and unpack the array, if it is contiguous
+ and not deferred or assumed shape. */
no_pack = ((sym && sym->as
&& !sym->attr.pointer
&& sym->as->type != AS_DEFERRED
@@ -5561,21 +5563,17 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, bool g77,
&& ref->u.ar.as->type != AS_DEFERRED
&& ref->u.ar.as->type != AS_ASSUMED_SHAPE));
- no_pack = g77 && !this_array_result
- && (expr->expr_type == EXPR_ARRAY || (contiguous && no_pack));
+ no_pack = g77 && !this_array_result && contiguous && no_pack;
- if (no_pack)
- {
- gfc_conv_expr_descriptor (se, expr, ss);
- if (expr->ts.type == BT_CHARACTER)
- se->string_length = expr->ts.u.cl->backend_decl;
- if (size)
- array_parameter_size (se->expr, expr, size);
- se->expr = gfc_conv_array_data (se->expr);
- return;
- }
+ /* Array constructors are always contiguous and do not need packing. */
+ array_constructor = g77 && !this_array_result && expr->expr_type == EXPR_ARRAY;
+
+ /* Same is true of contiguous sections from allocatable variables. */
+ good_allocatable = (g77 && !this_array_result && contiguous
+ && expr->symtree
+ && expr->symtree->n.sym->attr.allocatable);
- if (expr->expr_type == EXPR_ARRAY && g77)
+ if (no_pack || array_constructor || good_allocatable)
{
gfc_conv_expr_descriptor (se, expr, ss);
if (expr->ts.type == BT_CHARACTER)