+2008-02-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/34868
+ * trans-expr.c (gfc_conv_variable): Don't build indirect
+ references when explicit interface is mandated.
+ * resolve.c (resolve_formal_arglist): Set attr.always_explicit
+ on the result symbol as well as the procedure symbol.
+
2008-02-27 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/33387
if (gfc_elemental (proc)
|| sym->attr.pointer || sym->attr.allocatable
|| (sym->as && sym->as->rank > 0))
- proc->attr.always_explicit = 1;
+ {
+ proc->attr.always_explicit = 1;
+ sym->attr.always_explicit = 1;
+ }
formal_arg_flag = 1;
if ((sym->as && sym->as->rank > 0 && sym->as->type == AS_ASSUMED_SHAPE)
|| sym->attr.pointer || sym->attr.allocatable || sym->attr.target
|| sym->attr.optional)
- proc->attr.always_explicit = 1;
+ {
+ proc->attr.always_explicit = 1;
+ if (proc->result)
+ proc->result->attr.always_explicit = 1;
+ }
/* If the flavor is unknown at this point, it has to be a variable.
A procedure specification would have already set the type. */
/* Dereference scalar hidden result. */
if (gfc_option.flag_f2c && sym->ts.type == BT_COMPLEX
&& (sym->attr.function || sym->attr.result)
- && !sym->attr.dimension && !sym->attr.pointer)
+ && !sym->attr.dimension && !sym->attr.pointer
+ && !sym->attr.always_explicit)
se->expr = build_fold_indirect_ref (se->expr);
/* Dereference non-character pointer variables.
+2008-02-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/34868
+ * gfortran.dg/f2c_9.f90: New test.
+
2008-02-28 Sebastian Pop <sebastian.pop@amd.com>
* testsuite/gcc.dg/tree-ssa/ldist-1.c: New.
--- /dev/null
+! { dg-do run }
+! { dg-options "-ff2c" }
+! PR 34868
+
+function f(a) result(res)
+ implicit none
+ real(8), intent(in) :: a(:)
+ complex(8) :: res
+
+ res = cmplx(sum(a),product(a),8)
+end function f
+
+function g(a)
+ implicit none
+ real(8), intent(in) :: a(:)
+ complex(8) :: g
+
+ g = cmplx(sum(a),product(a),8)
+end function g
+
+program test
+ real(8) :: a(1,5)
+ complex(8) :: c
+ integer :: i
+
+ interface
+ complex(8) function f(a)
+ real(8), intent(in) :: a(:)
+ end function f
+ function g(a) result(res)
+ real(8), intent(in) :: a(:)
+ complex(8) :: res
+ end function g
+ end interface
+
+ do i = 1, 5
+ a(1,i) = sqrt(real(i,kind(a)))
+ end do
+
+ c = f(a(1,:))
+ call check (real(c), sum(a))
+ call check (imag(c), product(a))
+
+ c = g(a(1,:))
+ call check (real(c), sum(a))
+ call check (imag(c), product(a))
+contains
+ subroutine check (a, b)
+ real(8), intent(in) :: a, b
+ if (abs(a - b) > 1.e-10_8) call abort
+ end subroutine check
+end program test