summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authormikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-09 13:36:14 +0000
committermikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-09 13:36:14 +0000
commitee00cebbe3fd892c8c7456002628b227754ee1ff (patch)
treefff70f7f0c28192df8e62ca16e07ccec8557141d /gcc/fortran/trans-expr.c
parenta11ea431a147f7e7e269282b9453e57a01d84859 (diff)
downloadgcc-ee00cebbe3fd892c8c7456002628b227754ee1ff.tar.gz
Fix fortran/65894 elemental procedures wrong-code
gcc/fortran/ 2015-05-09 Mikael Morin <mikael@gcc.gnu.org> PR fortran/65894 * trans-array.h (gfc_scalar_elemental_arg_saved_as_reference): New prototype. * trans-array.c (gfc_scalar_elemental_arg_saved_as_reference): New function. (gfc_add_loop_ss_code): Use gfc_scalar_elemental_arg_saved_as_reference as conditional. (gfc_walk_elemental_function_args): Set the dummy_arg field. * trans.h (gfc_ss_info): New subfield dummy_arg. * trans-expr.c (gfc_conv_procedure_call): Revert the change of revision 222361. (gfc_conv_expr): Use gfc_scalar_elemental_arg_saved_as_reference as conditional. gcc/testsuite/ 2015-05-09 Andre Vehreschild <vehre@gmx.de> PR fortran/65894 * gfortran.dg/elemental_subroutine_11.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222968 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c20
1 files changed, 3 insertions, 17 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 9c5ce7d9df0..c71037f7b9a 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -4735,19 +4735,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
gfc_init_se (&parmse, se);
parm_kind = ELEMENTAL;
- /* For all value functions or polymorphic scalar non-pointer
- non-allocatable variables use the expression in e directly. This
- ensures, that initializers of polymorphic entities are correctly
- copied. */
- if (fsym && (fsym->attr.value
- || (e->expr_type == EXPR_VARIABLE
- && fsym->ts.type == BT_DERIVED
- && e->ts.type == BT_DERIVED
- && !e->ts.u.derived->attr.dimension
- && !e->rank
- && (!e->symtree
- || (!e->symtree->n.sym->attr.allocatable
- && !e->symtree->n.sym->attr.pointer)))))
+ if (fsym && fsym->attr.value)
gfc_conv_expr (&parmse, e);
else
gfc_conv_expr_reference (&parmse, e);
@@ -7310,11 +7298,9 @@ gfc_conv_expr (gfc_se * se, gfc_expr * expr)
ss_info = ss->info;
/* Substitute a scalar expression evaluated outside the scalarization
- loop. */
+ loop. */
se->expr = ss_info->data.scalar.value;
- /* If the reference can be NULL, the value field contains the reference,
- not the value the reference points to (see gfc_add_loop_ss_code). */
- if (ss_info->can_be_null_ref)
+ if (gfc_scalar_elemental_arg_saved_as_reference (ss_info))
se->expr = build_fold_indirect_ref_loc (input_location, se->expr);
se->string_length = ss_info->string_length;