[gfortran, committed] PR 24008: require argument list for function entries

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Wed Nov 2 00:05:00 GMT 2005


Tobias Schlüter wrote:
>>It is clear that ENTRY foo RESULT (bar) should be disallowed, but
>>ENTRY foo
>>in FUNCTION IMHO shouldn't.
> 
> 
> Indeed, I read the BNF incorrectly.  Great you have such a good memory, I'll
> fix this.

I committed the following together with a reversal of my changes to
entry_9.f90 after testing as r106361.  (BTW that's not why I made this mistake
in the first place, but it's interesting to see that the syntax is different
from the one for functions, where the argument list is always required.)

Thanks, Jakub!

- Tobi

2005-11-01  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>

	* decl.c (gfc_match_entry): Correctly deal with argument list of
	function entries.

Index: decl.c
===================================================================
--- decl.c      (revision 106359)
+++ decl.c      (working copy)
@@ -2603,6 +2603,7 @@ gfc_match_entry (void)
   gfc_compile_state state;
   match m;
   gfc_entry_list *el;
+  locus old_loc;

   m = gfc_match_name (name);
   if (m != MATCH_YES)
@@ -2690,8 +2691,26 @@ gfc_match_entry (void)
     }
   else
     {
-      /* An entry in a function.  */
-      m = gfc_match_formal_arglist (entry, 0, 0);
+      /* An entry in a function.
+         We need to take special care because writing
+            ENTRY f()
+         as
+            ENTRY f
+         is allowed, whereas
+            ENTRY f() RESULT (r)
+         can't be written as
+            ENTRY f RESULT (r).  */
+      old_loc = gfc_current_locus;
+      if (gfc_match_eos () == MATCH_YES)
+       {
+         gfc_current_locus = old_loc;
+         /* Match the empty argument list, and add the interface to
+            the symbol.  */
+         m = gfc_match_formal_arglist (entry, 0, 1);
+       }
+      else
+       m = gfc_match_formal_arglist (entry, 0, 0);
+
       if (m != MATCH_YES)
        return MATCH_ERROR;



More information about the Fortran mailing list