From: Paul Thomas Date: Sun, 9 Feb 2014 19:45:06 +0000 (+0000) Subject: re PR fortran/59026 (ELEMENTAL procedure with VALUE arguments emits wrong code) X-Git-Tag: releases/gcc-4.9.0~991 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=56c78e5c22f59741aba3aac3fa89452895be36bf;p=thirdparty%2Fgcc.git re PR fortran/59026 (ELEMENTAL procedure with VALUE arguments emits wrong code) 2014-02-09 Paul Thomas PR fortran/59026 * trans-expr.c (gfc_conv_procedure_call): Pass the value of the actual argument to a formal argument with the value attribute in an elemental procedure. 2014-02-09 Paul Thomas PR fortran/59026 * gfortran.dg/elemental_by_value_1.f90 : New test From-SVN: r207645 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 052248c761e9..ab2171a811ab 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2014-02-09 Paul Thomas + + PR fortran/59026 + * trans-expr.c (gfc_conv_procedure_call): Pass the value of the + actual argument to a formal argument with the value attribute + in an elemental procedure. + 2014-02-08 Janus Weil Mikael Morin diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 12da0a0025e4..297ff6798836 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -4047,7 +4047,11 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, gfc_init_se (&parmse, se); parm_kind = ELEMENTAL; - gfc_conv_expr_reference (&parmse, e); + if (fsym && fsym->attr.value) + gfc_conv_expr (&parmse, e); + else + gfc_conv_expr_reference (&parmse, e); + if (e->ts.type == BT_CHARACTER && !e->rank && e->expr_type == EXPR_FUNCTION) parmse.expr = build_fold_indirect_ref_loc (input_location, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9b9d2cde8e73..d70b76235cfa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-02-09 Paul Thomas + + PR fortran/59026 + * gfortran.dg/elemental_by_value_1.f90 : New test + 2014-02-08 Janus Weil PR fortran/58470 diff --git a/gcc/testsuite/gfortran.dg/elemental_by_value_1.f90 b/gcc/testsuite/gfortran.dg/elemental_by_value_1.f90 new file mode 100644 index 000000000000..4fc59471b5b5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/elemental_by_value_1.f90 @@ -0,0 +1,22 @@ +! { dg-do run } +! +! PR fortran/59026 +! +! Contributed by F-X Coudert +! +! Failed to dereference the argument in scalarized loop. +! +elemental integer function foo(x) + integer, value :: x + foo = x + 1 +end function + + interface + elemental integer function foo(x) + integer, value :: x + end function + end interface + + if (foo(42) .ne. 43) call abort + if (any (foo([0,1]) .ne. [1,2])) call abort +end