summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-io.c
diff options
context:
space:
mode:
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-16 09:17:49 +0000
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-16 09:17:49 +0000
commit1033248c1aee0c38d5f37d1df79e0139a1d79e8e (patch)
tree0671456d4a0001c3c76dbc6dc8b6b3c8d5ac9a80 /gcc/fortran/trans-io.c
parent6a8fd95b693441373a689ad47e305d412e865351 (diff)
downloadgcc-1033248c1aee0c38d5f37d1df79e0139a1d79e8e.tar.gz
2007-09-16 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29396 PR fortran/29606 PR fortran/30625 PR fortran/30871 * trans.h : Add extra argument to gfc_build_array_ref. Rename gfc_conv_aliased_arg to gfc_conv_subref_array_arg. Move prototype of is_aliased_array to gfortran.h and rename it gfc_is_subref_array. Add field span to lang_decl, add a new decl lang specific flag accessed by GFC_DECL_SUBREF_ARRAY_P and a new type flag GFC_DECL_SUBREF_ARRAY_P. * trans.c (gfc_build_array_ref): Add the new argument, decl. If this is a subreference array pointer, use the lang_decl field 'span' to calculate the offset in bytes and use pointer arithmetic to address the element. * trans-array.c (gfc_conv_scalarized_array_ref, gfc_conv_array_ref): Add the backend declaration as the third field, if it is likely to be a subreference array pointer. (gfc_conv_descriptor_dimension, gfc_trans_array_ctor_element, gfc_trans_array_constructor_element, structure_alloc_comps, gfc_conv_array_index_offset): For all other references to gfc_build_array_ref, set the third argument to NULL. (gfc_get_dataptr_offset): New function. (gfc_conv_expr_descriptor): If the rhs of a pointer assignment is a subreference array, then calculate the offset to the subreference of the first element and set the descriptor data pointer to this, using gfc_get_dataptr_offset. trans-expr.c (gfc_get_expr_charlen): Use the expression for the character length for a character subreference. (gfc_conv_substring, gfc_conv_subref_array_arg): Add NULL for third argument in call to gfc_build_array_ref. (gfc_conv_aliased_arg): Rename to gfc_conv_subref_array_arg. (is_aliased_array): Remove. (gfc_conv_function_call): Change reference to is_aliased_array to gfc_is_subref_array and reference to gfc_conv_aliased_arg to gfc_conv_subref_array_arg. (gfc_trans_pointer_assignment): Add the array element length to the lang_decl 'span' field. * gfortran.h : Add subref_array_pointer to symbol_attribute and add the prototype for gfc_is_subref_array. * trans-stmt.c : Add NULL for third argument in all references to gfc_build_array_ref. * expr.c (gfc_is_subref_array): Renamed is_aliased_array. If this is a subreference array pointer, return true. (gfc_check_pointer_assign): If the rhs is a subreference array, set the lhs subreference_array_pointer attribute. * trans-decl.c (gfc_get_symbol_decl): Allocate the lang_decl field if the symbol is a subreference array pointer and set an initial value of zero for the 'span' field. * trans-io.c (set_internal_unit): Refer to is_subref_array and gfc_conv_subref_array_arg. (nml_get_addr_expr): Add NULL third argument to gfc_build_array_ref. (gfc_trans_transfer): Use the scalarizer for a subreference array. 2007-09-16 Paul Thomas <pault@gcc.gnu.org> PR fortran/29396 PR fortran/29606 PR fortran/30625 PR fortran/30871 * gfortran.dg/subref_array_pointer_1.f90: New test. * gfortran.dg/subref_array_pointer_2.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128523 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-io.c')
-rw-r--r--gcc/fortran/trans-io.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index 289c2d2e2fc..72875f1e7be 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -724,11 +724,11 @@ set_internal_unit (stmtblock_t * block, stmtblock_t * post_block,
{
se.ss = gfc_walk_expr (e);
- if (is_aliased_array (e))
+ if (is_subref_array (e))
{
/* Use a temporary for components of arrays of derived types
or substring array references. */
- gfc_conv_aliased_arg (&se, e, 0,
+ gfc_conv_subref_array_arg (&se, e, 0,
last_dt == READ ? INTENT_IN : INTENT_OUT);
tmp = build_fold_indirect_ref (se.expr);
se.expr = gfc_build_addr_expr (pchar_type_node, tmp);
@@ -1330,7 +1330,7 @@ nml_get_addr_expr (gfc_symbol * sym, gfc_component * c,
a RECORD_TYPE. */
if (array_flagged)
- tmp = gfc_build_array_ref (tmp, gfc_index_zero_node);
+ tmp = gfc_build_array_ref (tmp, gfc_index_zero_node, NULL);
/* Now build the address expression. */
@@ -1964,7 +1964,9 @@ gfc_trans_transfer (gfc_code * code)
gcc_assert (ref->type == REF_ARRAY);
}
- if (expr->ts.type != BT_DERIVED && ref && ref->next == NULL)
+ if (expr->ts.type != BT_DERIVED
+ && ref && ref->next == NULL
+ && !is_subref_array (expr))
{
/* Get the descriptor. */
gfc_conv_expr_descriptor (&se, expr, ss);