aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2010-04-24 09:28:32 +0000
committerPaul Thomas <pault@gcc.gnu.org>2010-04-24 09:28:32 +0000
commit991b4da12247eb3e688e47f393229cc098bc7cea (patch)
treef478c03fe05157ce3c385681dcb888a51104ffd8 /gcc/fortran
parent7b65808d33edf19143af6d0f272cf126f87ca147 (diff)
downloadgcc-991b4da12247eb3e688e47f393229cc098bc7cea.zip
gcc-991b4da12247eb3e688e47f393229cc098bc7cea.tar.gz
gcc-991b4da12247eb3e688e47f393229cc098bc7cea.tar.bz2
re PR fortran/43841 (Missing temporary for ELEMENTAL function call)
2010-04-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/43841 PR fortran/43843 * trans-expr.c (gfc_conv_expr): Supply an address expression for GFC_SS_REFERENCE. (gfc_conv_expr_reference): Call gfc_conv_expr and return for GFC_SS_REFERENCE. * trans-array.c (gfc_add_loop_ss_code): Store the value rather than the address of a GFC_SS_REFERENCE. * trans.h : Change comment on GFC_SS_REFERENCE. 2010-04-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/43841 PR fortran/43843 * gfortran.dg/elemental_scalar_args_1.f90 : New test. From-SVN: r158683
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog12
-rw-r--r--gcc/fortran/trans-array.c5
-rw-r--r--gcc/fortran/trans-expr.c8
-rw-r--r--gcc/fortran/trans.h5
4 files changed, 23 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 1c77717..6072c05 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,15 @@
+2010-04-24 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/43841
+ PR fortran/43843
+ * trans-expr.c (gfc_conv_expr): Supply an address expression for
+ GFC_SS_REFERENCE.
+ (gfc_conv_expr_reference): Call gfc_conv_expr and return for
+ GFC_SS_REFERENCE.
+ * trans-array.c (gfc_add_loop_ss_code): Store the value rather
+ than the address of a GFC_SS_REFERENCE.
+ * trans.h : Change comment on GFC_SS_REFERENCE.
+
2010-04-22 Richard Guenther <rguenther@suse.de>
PR fortran/43829
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 199eb23..c3a92bc 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -2054,9 +2054,10 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
break;
case GFC_SS_REFERENCE:
- /* Scalar reference. Evaluate this now. */
+ /* Scalar argument to elemental procedure. Evaluate this
+ now. */
gfc_init_se (&se, NULL);
- gfc_conv_expr_reference (&se, ss->expr);
+ gfc_conv_expr (&se, ss->expr);
gfc_add_block_to_block (&loop->pre, &se.pre);
gfc_add_block_to_block (&loop->post, &se.post);
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 42e1d34..dc138a3 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -4541,6 +4541,8 @@ gfc_conv_expr (gfc_se * se, gfc_expr * expr)
/* Substitute a scalar expression evaluated outside the scalarization
loop. */
se->expr = se->ss->data.scalar.expr;
+ if (se->ss->type == GFC_SS_REFERENCE)
+ se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
se->string_length = se->ss->string_length;
gfc_advance_se_ss_chain (se);
return;
@@ -4661,9 +4663,9 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr)
if (se->ss && se->ss->expr == expr
&& se->ss->type == GFC_SS_REFERENCE)
{
- se->expr = se->ss->data.scalar.expr;
- se->string_length = se->ss->string_length;
- gfc_advance_se_ss_chain (se);
+ /* Returns a reference to the scalar evaluated outside the loop
+ for this case. */
+ gfc_conv_expr (se, expr);
return;
}
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 91f1b77..b332c8e 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -126,8 +126,9 @@ typedef enum
scalarization loop. */
GFC_SS_SCALAR,
- /* Like GFC_SS_SCALAR except it evaluates a pointer to the expression.
- Used for elemental function parameters. */
+ /* Like GFC_SS_SCALAR it evaluates the expression outside the
+ loop. Is always evaluated as a reference to the temporary.
+ Used for elemental function arguments. */
GFC_SS_REFERENCE,
/* An array section. Scalarization indices will be substituted during