Dear all,
I have no idea about the scalarizer, but the attached patch fixes the
test case and somehow adding an array ref to a scalar looks odd to me ...
(Before the regression-causing patch, only the "else" branch existed.)
Build and regtested on x86-64-linux.
OK for the trunk?
Tobias
2012-01-31 Tobias Burnus
PR fortran/52059
* trans-expr.c (gfc_conv_procedure_call): Add array ref
only to variables.
2012-01-31 Tobias Burnus
PR fortran/52059
* gfortran.dg/elemental_function_1.f90: New.
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (Revision 183775)
+++ gcc/fortran/trans-expr.c
@@ -3519,21 +3519,21 @@ gfc_conv_procedure_call (gfc_se * se, gf
CLASS object. */
gfc_init_se (&parmse, se);
gfc_conv_derived_to_class (&parmse, e, fsym->ts);
}
else if (se->ss && se->ss->info->useflags)
{
/* An elemental function inside a scalarized loop. */
gfc_init_se (&parmse, se);
parm_kind = ELEMENTAL;
- if (se->ss->dimen > 0
+ if (se->ss->dimen > 0 && e->expr_type == EXPR_VARIABLE
&& se->ss->info->data.array.ref == NULL)
{
gfc_conv_tmp_array_ref (&parmse);
if (e->ts.type == BT_CHARACTER)
gfc_conv_string_parameter (&parmse);
else
parmse.expr = gfc_build_addr_expr (NULL_TREE, parmse.expr);
}
else
gfc_conv_expr_reference (&parmse, e);
Index: gcc/testsuite/gfortran.dg/elemental_function_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/elemental_function_1.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/elemental_function_1.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+!
+! PR fortran/52059
+!
+!
+
+subroutine baz
+ real(kind=8) :: a(99), b
+ interface bar
+ function bar (x, y)
+ integer, intent(in) :: x, y
+ real(kind=8), dimension((y-x)) :: bar
+ end function bar
+ end interface
+ b = 1.0_8
+ a = foo (bar(0,35) / dble(34), b)
+contains
+ elemental real(kind=8) function foo(x, y)
+ real(kind=8), intent(in) :: x, y
+ foo = 1
+ end function foo
+end subroutine baz