From a81a6d58367e63f3c7314eb793002e5feb379428 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Tue, 15 Jan 2019 20:17:35 +0000 Subject: [PATCH] re PR fortran/81849 (Size of automatic array argument specified by host-associated variable.) 2019-01-15 Steven G. Kargl PR fortran/81849 * resolve.c (resolve_symbol): Host associated varaibles can appear in the specification statement of a RESULT array. 2019-01-15 Steven G. Kargl PR fortran/81849 * gfortran.dg/pr81849.f90: New test. From-SVN: r267948 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr81849.f90 | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr81849.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a8cb6dd505f..76a840db864 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-01-15 Steven G. Kargl + + PR fortran/81849 + * resolve.c (resolve_symbol): Host associated varaibles can appear + in the specification statement of a RESULT array. + 2019-01-15 Paul Thomas * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Deal with exprs diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 155e7c921cf..7fbfa693526 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d38a5783686..56265c8641b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-15 Steven G. Kargl + + PR fortran/81849 + * gfortran.dg/pr81849.f90: New test. + 2019-01-15 Paul Thomas * gfortran.dg/ISO_Fortran_binding_2.c : Change reference to diff --git a/gcc/testsuite/gfortran.dg/pr81849.f90 b/gcc/testsuite/gfortran.dg/pr81849.f90 new file mode 100644 index 00000000000..e2f2d6ffbed --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr81849.f90 @@ -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 -- 2.30.2