This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran] Allow ENTRY without RESULT (PR30873)
- From: Tobias Burnus <burnus at net-b dot de>
- To: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 02 Mar 2007 09:49:51 +0100
- Subject: [Patch, Fortran] Allow ENTRY without RESULT (PR30873)
:ADDPATCH fortran:
gfortran did not like
ENTRY E1(I)
without
RESULT(result-name)
And prints this error:
- gfc_error ("RESULT attribute required in ENTRY statement at %C");
However, the Fortran standard permits this and uses then the entry-name
as result-name - similar to functions without result-name.
R1235 entry-stmt is ENTRY entry-name [ ( [ dummy-arg-list ] ) [ suffix ] ]
C1252 (R1235) If RESULT is specified, the entry-name shall not appear in
any specification or type declaration statement in the scoping unit of
the function program.
C1254 (R1235) RESULT shall appear only if the entry-stmt is in a
function subprogram.
C1257 (R1235) If RESULT is specified, result-name shall not be the same
as the function-name in the FUNCTION statement and shall not be the same
as the entry-name in any ENTRY statement in the subprogram.
Found by Joost VandeVondele, thanks!
I could trace this check back to r69825:
* gcc/fortran: New front end.
This check is also no longer part of g95.
Bootstrapped and regression tested on x86_64-unknown-linux-gnu
Ok for the trunk, 4.2 and for 4.1?
Tobias
2007-03-02 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30873
* decl.c (gfc_match_entry): Remove erroneous entry result check.
2007-03-02 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30873
* gfortran.dg/entry_9.f90: New test.
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (Revision 122469)
+++ gcc/fortran/decl.c (Arbeitskopie)
@@ -3030,12 +3030,6 @@
entry->result = result;
}
-
- if (proc->attr.recursive && result == NULL)
- {
- gfc_error ("RESULT attribute required in ENTRY statement at %C");
- return MATCH_ERROR;
- }
}
if (gfc_match_eos () != MATCH_YES)
Index: gcc/testsuite/gfortran.dg/entry_9.f90
===================================================================
--- gcc/testsuite/gfortran.dg/entry_9.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/entry_9.f90 (Revision 0)
@@ -0,0 +1,31 @@
+! { dg-do "run" }
+! Check whether RESULT of ENTRY defaults to entry-name.
+! PR fortran/30873
+!
+! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
+!
+MODULE M1
+ CONTAINS
+ FUNCTION F2(K)
+ INTEGER :: F2,K
+ F2=E1(K)
+ END FUNCTION F2
+
+ RECURSIVE FUNCTION F1(I)
+ INTEGER :: F1,I,E1
+ F1=F2(I)
+ RETURN
+ ENTRY E1(I)
+ E1=-I
+ RETURN
+ END FUNCTION F1
+END MODULE M1
+
+program main
+ use m1
+ if (E1(5) /= -5) call abort()
+ if (F2(4) /= -4) call abort()
+ if (F1(1) /= -1) call abort()
+end program main
+
+! { dg-final { cleanup-modules "m1" } }