aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2005-11-30 17:26:40 +0000
committerPaul Thomas <pault@gcc.gnu.org>2005-11-30 17:26:40 +0000
commit99c7ab426c16387fb2a27681f54b0ca4ff853b69 (patch)
tree4cab46bed130eb0f0b7437bac89bbc2298702409 /gcc/fortran
parente541c31f4ca60209f17d3b44d365cfee4659b899 (diff)
downloadgcc-99c7ab426c16387fb2a27681f54b0ca4ff853b69.zip
gcc-99c7ab426c16387fb2a27681f54b0ca4ff853b69.tar.gz
gcc-99c7ab426c16387fb2a27681f54b0ca4ff853b69.tar.bz2
[multiple changes]
2005-11-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/15809 * trans-decl.c (gfc_get_symbol_decl): In the case of automatic character length, dummy pointer arrays, build an expression for unit size of the array elements, to be picked up and used in the descriptor dtype. * trans-io.c (gfc_trans_transfer): Modify the detection of components of derived type arrays to use the gfc_expr references instead of the array descriptor dtype. This allows the latter to contain expressions. 2005-11-30 Erik Edelmann <erik.edelmann@iki.fi> PR fortran/15809 * trans-array.c (gfc_trans_deferred_array): Allow PARM_DECLs past in addition to VAR_DECLs. 2005-11-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/15809 * gfortran.dg/auto_char_dummy_array.f90: New test. From-SVN: r107727
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog18
-rw-r--r--gcc/fortran/trans-array.c4
-rw-r--r--gcc/fortran/trans-decl.c18
-rw-r--r--gcc/fortran/trans-io.c40
4 files changed, 55 insertions, 25 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 5aafa48..a55a828 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,21 @@
+2005-11-30 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/15809
+ * trans-decl.c (gfc_get_symbol_decl): In the case of automatic
+ character length, dummy pointer arrays, build an expression for
+ unit size of the array elements, to be picked up and used in the
+ descriptor dtype.
+ * trans-io.c (gfc_trans_transfer): Modify the detection of
+ components of derived type arrays to use the gfc_expr references
+ instead of the array descriptor dtype. This allows the latter
+ to contain expressions.
+
+2005-11-30 Erik Edelmann <erik.edelmann@iki.fi>
+
+ PR fortran/15809
+ * trans-array.c (gfc_trans_deferred_array): Allow PARM_DECLs past
+ in addition to VAR_DECLs.
+
2005-11-29 Jakub Jelinek <jakub@redhat.com>
* io.c (gfc_resolve_open): RESOLVE_TAG access field as well.
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 20d3c67..a94d7e8 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -4173,7 +4173,9 @@ gfc_trans_deferred_array (gfc_symbol * sym, tree body)
gfc_init_block (&fnblock);
- gcc_assert (TREE_CODE (sym->backend_decl) == VAR_DECL);
+ gcc_assert (TREE_CODE (sym->backend_decl) == VAR_DECL
+ || TREE_CODE (sym->backend_decl) == PARM_DECL);
+
if (sym->ts.type == BT_CHARACTER
&& !INTEGER_CST_P (sym->ts.cl->backend_decl))
gfc_trans_init_string_length (sym->ts.cl, &fnblock);
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 37e9db8..63320ae 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -809,7 +809,9 @@ tree
gfc_get_symbol_decl (gfc_symbol * sym)
{
tree decl;
+ tree etype = NULL_TREE;
tree length = NULL_TREE;
+ tree tmp = NULL_TREE;
int byref;
gcc_assert (sym->attr.referenced);
@@ -845,6 +847,22 @@ gfc_get_symbol_decl (gfc_symbol * sym)
if (TREE_CODE (length) != INTEGER_CST)
{
gfc_finish_var_decl (length, sym);
+
+ /* Set the element size of automatic character length
+ length, dummy, pointer arrays. */
+ if (sym->attr.pointer && sym->attr.dummy
+ && sym->attr.dimension)
+ {
+ tmp = gfc_build_indirect_ref (sym->backend_decl);
+ etype = gfc_get_element_type (TREE_TYPE (tmp));
+ if (TYPE_SIZE_UNIT (etype) == NULL_TREE)
+ {
+ tmp = TYPE_SIZE_UNIT (gfc_character1_type_node);
+ tmp = fold_convert (TREE_TYPE (tmp), length);
+ TYPE_SIZE_UNIT (etype) = tmp;
+ }
+ }
+
gfc_defer_symbol_init (sym);
}
}
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index 720ff58..98c1d1f 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -1768,6 +1768,7 @@ gfc_trans_transfer (gfc_code * code)
stmtblock_t block, body;
gfc_loopinfo loop;
gfc_expr *expr;
+ gfc_ref *ref;
gfc_ss *ss;
gfc_se se;
tree tmp;
@@ -1778,6 +1779,7 @@ gfc_trans_transfer (gfc_code * code)
expr = code->expr;
ss = gfc_walk_expr (expr);
+ ref = NULL;
gfc_init_se (&se, NULL);
if (ss == gfc_ss_terminator)
@@ -1788,33 +1790,23 @@ gfc_trans_transfer (gfc_code * code)
}
else
{
- /* Transfer an array. There are 3 options:
- 1) An array of an intrinsic type. This is handled by transfering
- the descriptor to the library.
- 2) A derived type containing an array. Scalarized by the frontend.
- 3) An array of derived type. Scalarized by the frontend.
- */
- if (expr->ts.type != BT_DERIVED)
+ /* Transfer an array. If it is an array of an intrinsic
+ type, pass the descriptor to the library. Otherwise
+ scalarize the transfer. */
+ if (expr->ref)
+ {
+ for (ref = expr->ref; ref && ref->type != REF_ARRAY;
+ ref = ref->next);
+ gcc_assert (ref->type == REF_ARRAY);
+ }
+
+ if (expr->ts.type != BT_DERIVED && ref && ref->next == NULL)
{
/* Get the descriptor. */
gfc_conv_expr_descriptor (&se, expr, ss);
- /* If it's not an array of derived type, transfer the array
- descriptor to the library. */
- tmp = gfc_get_dtype (TREE_TYPE (se.expr));
- if (((TREE_INT_CST_LOW (tmp) & GFC_DTYPE_TYPE_MASK)
- >> GFC_DTYPE_TYPE_SHIFT) != GFC_DTYPE_DERIVED)
- {
- tmp = gfc_build_addr_expr (NULL, se.expr);
- transfer_array_desc (&se, &expr->ts, tmp);
- goto finish_block_label;
- }
- else
- {
- /* Cleanup the mess getting the descriptor caused. */
- expr = code->expr;
- ss = gfc_walk_expr (expr);
- gfc_init_se (&se, NULL);
- }
+ tmp = gfc_build_addr_expr (NULL, se.expr);
+ transfer_array_desc (&se, &expr->ts, tmp);
+ goto finish_block_label;
}
/* Initialize the scalarizer. */