2014-02-09 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Feb 2014 19:45:06 +0000 (19:45 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Feb 2014 19:45:06 +0000 (19:45 +0000)
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  <pault@gcc.gnu.org>

PR fortran/59026
* gfortran.dg/elemental_by_value_1.f90 : New test

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207645 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/elemental_by_value_1.f90 [new file with mode: 0644]

index 052248c..ab2171a 100644 (file)
@@ -1,3 +1,10 @@
+2014-02-09  Paul Thomas  <pault@gcc.gnu.org>
+
+       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  <janus@gcc.gnu.org>
            Mikael Morin <mikael.morin@gcc.gnu.org>
 
index 12da0a0..297ff67 100644 (file)
@@ -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,
index 9b9d2cd..d70b762 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-09  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/59026
+       * gfortran.dg/elemental_by_value_1.f90 : New test
+
 2014-02-08  Janus Weil  <janus@gcc.gnu.org>
 
        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 (file)
index 0000000..4fc5947
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do run }
+!
+! PR fortran/59026
+!
+! Contributed by F-X Coudert  <fxcoudert@gcc.gnu.org>
+!
+! 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