diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/expr.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/ptr-func-4.f90 | 19 |
2 files changed, 22 insertions, 1 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 92a6700..956003e 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -6121,7 +6121,9 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj, } if (!pointer && sym->attr.flavor != FL_VARIABLE && !(sym->attr.flavor == FL_PROCEDURE && sym == sym->result) - && !(sym->attr.flavor == FL_PROCEDURE && sym->attr.proc_pointer)) + && !(sym->attr.flavor == FL_PROCEDURE && sym->attr.proc_pointer) + && !(sym->attr.flavor == FL_PROCEDURE + && sym->attr.function && sym->attr.pointer)) { if (context) gfc_error ("%qs in variable definition context (%s) at %L is not" diff --git a/gcc/testsuite/gfortran.dg/ptr-func-4.f90 b/gcc/testsuite/gfortran.dg/ptr-func-4.f90 new file mode 100644 index 0000000..62b18f6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ptr-func-4.f90 @@ -0,0 +1,19 @@ +! { dg-do run } +! { dg-options "-O2 -std=f2008" } +! PR fortran/100218 - target of pointer from evaluation of function-reference + +program p + implicit none + integer, target :: z = 0 + call g (f ()) + if (z /= 1) stop 1 +contains + function f () result (r) + integer, pointer :: r + r => z + end function f + subroutine g (x) + integer, intent(out) :: x + x = 1 + end subroutine g +end program p |