===================================================================
@@ -15345,7 +15345,7 @@ resolve_symbol (gfc_symbol *sym)
/* Set the formal_arg_flag so that check_conflict will not throw
an error for host associated variables in the specification
expression for an array_valued function. */
- if (sym->attr.function && sym->as)
+ if ((sym->attr.function || sym->attr.result) && sym->as)
formal_arg_flag = true;
saved_specification_expr = specification_expr;
===================================================================
@@ -0,0 +1,16 @@
+! { dg-do run }
+! PR fortran/81849
+program p
+ implicit none
+ integer :: n=3
+ if (any(g() /= f())) stop 1
+ contains
+ function g()
+ real g(n)
+ g = 7
+ end function g
+ function f() result(r)
+ real r(n)
+ r = 7
+ end function f
+end program