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]

[PATCH] Allow omitting parentheses for ENTRY even in FUNCTIONs


Hi!

gfortran only permits ENTRY foo without () in SUBROUTINEs, but not
in FUNCTIONs.  g77 accepted omitting parentheses in both SOUBROUTINEs
and FUNCTIONs and I can't find any wording in either F95 or F2003 standards
that would disallow that.  There is just one entry-stmt and it has ()s
optional and nothing says explicitely that parentheses must be used
when ENTRY is present in a function.

2005-07-04  Jakub Jelinek  <jakub@redhat.com>

	* decl.c (gfc_match_entry): Allow ENTRY without parentheses
	even in FUNCTIONs.

	* gfortran.fortran-torture/execute/entry_9.f90: New test.

--- gcc/fortran/decl.c.jj	2005-07-02 02:28:31.000000000 +0200
+++ gcc/fortran/decl.c	2005-07-04 22:18:20.000000000 +0200
@@ -2395,7 +2395,7 @@ gfc_match_entry (void)
   else
     {
       /* An entry in a function.  */
-      m = gfc_match_formal_arglist (entry, 0, 0);
+      m = gfc_match_formal_arglist (entry, 0, 1);
       if (m != MATCH_YES)
 	return MATCH_ERROR;
 
--- gcc/testsuite/gfortran.fortran-torture/execute/entry_9.f90.jj	2005-07-04 22:15:02.000000000 +0200
+++ gcc/testsuite/gfortran.fortran-torture/execute/entry_9.f90	2005-07-04 22:10:31.000000000 +0200
@@ -0,0 +1,24 @@
+! Test alternate entry points for functions when the result types
+! of all entry points match
+
+	function f1 (a)
+	integer a, f1, e1
+	f1 = 15 + a
+	return
+	entry e1
+	e1 = 42
+	end function
+	function f2 ()
+	real f2, e2
+	entry e2
+	e2 = 45
+	end function
+
+	program entrytest
+	integer f1, e1
+	real f2, e2
+	if (f1 (6) .ne. 21) call abort ()
+	if (e1 () .ne. 42) call abort ()
+	if (f2 () .ne. 45) call abort ()
+	if (e2 () .ne. 45) call abort ()
+	end

	Jakub


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