From 5f0367d00a18d036cb0d2f7457daeca50d623d8e Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Sun, 11 Feb 2018 18:55:31 +0000 Subject: [PATCH] re PR fortran/35299 (scope of variables in statement function do not acquire rank from host) 2018-02-11 Francois-Xavier Coudert PR fortran/35299 * gfortran.dg/statement_function_3.f: New test. 2018-02-11 Francois-Xavier Coudert PR fortran/35299 * resolve.c (resolve_formal_arglist): Update error message. From-SVN: r257566 --- gcc/fortran/resolve.c | 7 +++++-- gcc/testsuite/gfortran.dg/statement_function_3.f | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/statement_function_3.f diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 60b9bc306ef..429c1c481ca 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -512,8 +512,11 @@ resolve_formal_arglist (gfc_symbol *proc) { if (sym->as != NULL) { - gfc_error ("Argument %qs of statement function at %L must " - "be scalar", sym->name, &sym->declared_at); + /* F03:C1263 (R1238) The function-name and each dummy-arg-name + shall be specified, explicitly or implicitly, to be scalar. */ + gfc_error ("Argument '%s' of statement function '%s' at %L " + "must be scalar", sym->name, proc->name, + &proc->declared_at); continue; } diff --git a/gcc/testsuite/gfortran.dg/statement_function_3.f b/gcc/testsuite/gfortran.dg/statement_function_3.f new file mode 100644 index 00000000000..dcfb3e2b9dc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/statement_function_3.f @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/35299 + subroutine phtod(e,n,i,h) + dimension e(n) + hstar(e,b)=b**.4*((1.25*fun(-e/40)+.18)) ! { dg-error "must be scalar" } + a = 1. + h = hstar(e(i-1), a) + end + + function fun(a) + real a(*) + fun = 42 + end +! { dg-prune-output " Obsolescent feature" } + -- 2.30.2