re PR fortran/35299 (scope of variables in statement function do not acquire rank...
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Sun, 11 Feb 2018 18:55:31 +0000 (18:55 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sun, 11 Feb 2018 18:55:31 +0000 (18:55 +0000)
2018-02-11  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

PR fortran/35299
* gfortran.dg/statement_function_3.f: New test.

2018-02-11  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

PR fortran/35299
* resolve.c (resolve_formal_arglist): Update error message.

From-SVN: r257566

gcc/fortran/resolve.c
gcc/testsuite/gfortran.dg/statement_function_3.f [new file with mode: 0644]

index 60b9bc306ef9b295abba39fbde73f8082009c40a..429c1c481cafae082540912ecb30224f628a5a92 100644 (file)
@@ -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 (file)
index 0000000..dcfb3e2
--- /dev/null
@@ -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" }
+