Bug 20865 - statement function shall not be supplied as procedure argument
Summary: statement function shall not be supplied as procedure argument
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Francois-Xavier Coudert
URL: http://gcc.gnu.org/ml/fortran/2005-04...
Keywords: accepts-invalid, patch
Depends on:
Blocks:
 
Reported: 2005-04-08 15:57 UTC by Joost VandeVondele
Modified: 2005-04-28 13:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-04-28 07:58:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2005-04-08 15:57:00 UTC
The following is non-standard and the compiler should probably generate a
warning/error with '-pedantic -std=f95'



  INTEGER :: I,st1
  st1(I)=(I*I+2)
  CALL TT(st1) ! 12.5.4
  END
  SUBROUTINE TT(st1)
   INTEGER :: st1
  END SUBROUTINE
Comment 1 Francois-Xavier Coudert 2005-04-28 07:58:02 UTC
Possible patch:

diff -p -u -r1.39 resolve.c
--- gcc/fortran/resolve.c       19 Mar 2005 19:45:33 -0000      1.39
+++ gcc/fortran/resolve.c       28 Apr 2005 07:56:12 -0000
@@ -616,6 +616,13 @@ resolve_actual_arglist (gfc_actual_argli
          continue;
        }
 
+      if (sym->attr.flavor == FL_PROCEDURE &&
+         sym->attr.proc == PROC_ST_FUNCTION)
+        {
+         gfc_error ("Statement function '%s' at %L is not allowed as an "
+                    "actual argument", sym->name, &e->where);
+       }
+
       /* See if the name is a module procedure in a parent unit.  */
 
       if (was_declared (sym) || sym->ns->parent == NULL)


I will look to see if I forgot something, then regtest, then post it.
Comment 2 Francois-Xavier Coudert 2005-04-28 09:19:20 UTC
It does not fix the error. Will look further into it.
Comment 3 Francois-Xavier Coudert 2005-04-28 11:34:56 UTC
New patch proposed: http://gcc.gnu.org/ml/fortran/2005-04/msg00667.html
Comment 4 CVS Commits 2005-04-28 11:56:18 UTC
Subject: Bug 20865

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	fxcoudert@gcc.gnu.org	2005-04-28 11:56:03

Modified files:
	gcc/fortran    : ChangeLog resolve.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: pr20865.f90 

Log message:
	PR fortran/20865
	* resolve.c (resolve_actual_arglist): Issue an error if a statement
	functions is used as actual argument.
	* gfortran.dg/pr20865.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335.2.40&r2=1.335.2.41
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/resolve.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.34.2.5&r2=1.34.2.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.145&r2=1.5084.2.146
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/pr20865.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 5 CVS Commits 2005-04-28 11:56:18 UTC
Subject: Bug 20865

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	fxcoudert@gcc.gnu.org	2005-04-28 11:56:08

Modified files:
	gcc/fortran    : ChangeLog resolve.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: pr20865.f90 

Log message:
	PR fortran/20865
	* resolve.c (resolve_actual_arglist): Issue an error if a statement
	functions is used as actual argument.
	* gfortran.dg/pr20865.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.407&r2=1.408
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/resolve.c.diff?cvsroot=gcc&r1=1.40&r2=1.41
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5409&r2=1.5410
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/pr20865.f90.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 6 Andrew Pinski 2005-04-28 13:24:58 UTC
Fixed.