2020-12-05 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/98016
* resolve.c (resolve_symbol): Set formal_arg_flag before
resolving an array spec and restore value afterwards.
gcc/testsuite/
PR fortran/98016
* gfortran.dg/pr98016.f90: New test.
else if (mp_flag && sym->attr.flavor == FL_PROCEDURE && sym->attr.function)
{
bool saved_specification_expr = specification_expr;
+ bool saved_formal_arg_flag = formal_arg_flag;
+
specification_expr = true;
+ formal_arg_flag = true;
gfc_resolve_array_spec (sym->result->as, false);
+ formal_arg_flag = saved_formal_arg_flag;
specification_expr = saved_specification_expr;
}
--- /dev/null
+! { dg-do compile }
+!
+! Fix for PR98016 - Used to fail with Error: Variable ānā cannot appear in the
+! expression at (1) for line 16. Workaround was to declare y to be real.
+!
+! Posted by Juergen Reuter <juergen.reuter@desy.de>
+!
+program is_it_valid
+ dimension y(3)
+ n=3
+ y=func(1.0)
+ print *, y
+ stop
+contains
+ function func(x) result (y)
+ dimension y(n)
+ y=x
+ end function
+end