diff options
author | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-02 11:58:02 +0000 |
---|---|---|
committer | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-02 11:58:02 +0000 |
commit | 34de9f8b3f212ffcb65ba1f4bb8f697c6ecf336a (patch) | |
tree | 822cb28ea2dcad6f2050a6923d4526c2f85af09e /gcc/fortran/trans-array.c | |
parent | 44f1d7db60ef0b1ff67fcd94b903865d551ab5af (diff) | |
download | gcc-34de9f8b3f212ffcb65ba1f4bb8f697c6ecf336a.tar.gz |
2010-03-02 Paul Thomas <pault@gcc.gnu.org>
PR fortran/43180
* trans-array.c (gfc_conv_array_parameter): A full array of
derived type need not be restricted to a symbol without an
array spec to use the call to gfc_conv_expr_descriptor.
PR fortran/43173
* trans-array.c (gfc_conv_array_parameter): Contiguous refs to
allocatable arrays do not need temporaries.
2010-03-02 Paul Thomas <pault@gcc.gnu.org>
PR fortran/43180
* gfortran.dg/internal_pack_10.f90: New test.
PR fortran/43173
* gfortran.dg/internal_pack_11.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157163 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 2ea978d0ece..c8728899c6d 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) |