diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2010-02-20 12:46:43 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2010-02-20 12:46:43 +0000 |
commit | f7172b55bb859fd27939374247df4cb0a24f03c0 (patch) | |
tree | d1b425ccdec447a40c7a383fc38708be8c41cc3e /gcc/fortran/trans-array.c | |
parent | e7a8485402327fdc5843b7ec0228c6e70ed1919f (diff) | |
download | gcc-f7172b55bb859fd27939374247df4cb0a24f03c0.zip gcc-f7172b55bb859fd27939374247df4cb0a24f03c0.tar.gz gcc-f7172b55bb859fd27939374247df4cb0a24f03c0.tar.bz2 |
re PR fortran/36932 (unneeded temporary (2x))
2010-02-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36932
PR fortran/36933
PR fortran/43072
PR fortran/43111
* dependency.c (gfc_check_argument_var_dependency): Use enum
value instead of arithmetic vaue for 'elemental'.
(check_data_pointer_types): New function.
(gfc_check_dependency): Call check_data_pointer_types.
* trans-array.h : Change fourth argument of
gfc_conv_array_parameter to boolean.
* trans-array.c (gfc_conv_array_parameter): A contiguous array
can be a dummy but it must not be assumed shape or deferred.
Change fourth argument to boolean. Array constructor exprs will
always be contiguous and do not need packing and unpacking.
* trans-expr.c (gfc_conv_procedure_call): Clean up some white
space and change fourth argument of gfc_conv_array_parameter
to boolean.
(gfc_trans_arrayfunc_assign): Change fourth argument of
gfc_conv_array_parameter to boolean.
* trans-io.c (gfc_convert_array_to_string): The same.
* trans-intrinsic.c (gfc_conv_intrinsic_loc): The same.
2010-02-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36932
PR fortran/36933
* gfortran.dg/dependency_26.f90: New test.
PR fortran/43072
* gfortran.dg/internal_pack_7.f90: New test.
PR fortran/43111
* gfortran.dg/internal_pack_8.f90: New test.
From-SVN: r156926
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index ae39aed..2ea978d 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -5459,7 +5459,7 @@ array_parameter_size (tree desc, gfc_expr *expr, tree *size) /* TODO: Optimize passing g77 arrays. */ void -gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, +gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, bool g77, const gfc_symbol *fsym, const char *proc_name, tree *size) { @@ -5471,6 +5471,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, bool full_array_var; bool this_array_result; bool contiguous; + bool no_pack; gfc_symbol *sym; stmtblock_t block; gfc_ref *ref; @@ -5519,8 +5520,10 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, return; } - if (!sym->attr.pointer && sym->as->type != AS_ASSUMED_SHAPE - && !sym->attr.allocatable) + if (!sym->attr.pointer + && sym->as + && sym->as->type != AS_ASSUMED_SHAPE + && !sym->attr.allocatable) { /* Some variables are declared directly, others are declared as pointers and allocated on the heap. */ @@ -5547,8 +5550,32 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, } } - if (contiguous && g77 && !this_array_result - && !expr->symtree->n.sym->attr.dummy) + /* There is no need to pack and unpack the array, if it is an array + constructor or contiguous and not deferred or assumed shape. */ + no_pack = ((sym && sym->as + && !sym->attr.pointer + && sym->as->type != AS_DEFERRED + && sym->as->type != AS_ASSUMED_SHAPE) + || + (ref && ref->u.ar.as + && 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)); + + 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; + } + + if (expr->expr_type == EXPR_ARRAY && g77) { gfc_conv_expr_descriptor (se, expr, ss); if (expr->ts.type == BT_CHARACTER) @@ -5601,7 +5628,6 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, { desc = se->expr; /* Repack the array. */ - if (gfc_option.warn_array_temp) { if (fsym) |