This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] patch PR fortran/20865


Statement functions should not be used as actual arguments. This patch enables gfortran to issue an error on such code (PR fortran/20865).

Regtested on i386-linux. OK for mainline and 4.0?

FX
2005-04-29  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

	PR fortran/20865
	* resolve.c (resolve_actual_arglist): Issue an error if a statement
	functions is used as actual argument.


2005-04-29  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

	PR fortran/20865
	* gfortran.dg/pr20865.f90: New test.

Index: gcc/fortran/resolve.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/resolve.c,v
retrieving revision 1.40
diff -p -u -r1.40 resolve.c
--- gcc/fortran/resolve.c	19 Apr 2005 07:10:03 -0000	1.40
+++ gcc/fortran/resolve.c	28 Apr 2005 11:18:16 -0000
@@ -604,6 +604,12 @@ resolve_actual_arglist (gfc_actual_argli
 	  || sym->attr.external)
 	{
 
+          if (sym->attr.proc == PROC_ST_FUNCTION)
+            {
+              gfc_error ("Statement function '%s' at %L is not allowed as an "
+                         "actual argument", sym->name, &e->where);
+            }
+
 	  /* If the symbol is the function that names the current (or
 	     parent) scope, then we really have a variable reference.  */
 
! { dg-do compile }
! PR fortran/20865
  subroutine tt(j)
   integer :: j
  end subroutine

  integer :: i, st
  st(i) = (i*i+2)
  call tt(st) ! { dg-error "Statement function .* is not allowed as an actual argument" }
  end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]