[PATCH] Fix use of ENTRY names as rvalues

Jakub Jelinek jakub@redhat.com
Thu Jul 7 11:59:00 GMT 2005


Hi!

Without this gfortran complains at the bar / 3 spot
that function bar requires an argument list.
Ok to commit (HEAD + 4.0.2 (after it reopens))?

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

	* primary.c (gfc_match_rvalue): Handle ENTRY the same way
	as FUNCTION.

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

--- gcc/fortran/primary.c.jj	2005-07-07 13:01:20.000000000 +0200
+++ gcc/fortran/primary.c	2005-07-07 13:54:44.000000000 +0200
@@ -1846,11 +1846,24 @@ gfc_match_rvalue (gfc_expr ** result)
 
   gfc_set_sym_referenced (sym);
 
-  if (sym->attr.function && sym->result == sym
-      && (gfc_current_ns->proc_name == sym
+  if (sym->attr.function && sym->result == sym)
+    {
+      if (gfc_current_ns->proc_name == sym
 	  || (gfc_current_ns->parent != NULL
-	      && gfc_current_ns->parent->proc_name == sym)))
-    goto variable;
+	      && gfc_current_ns->parent->proc_name == sym))
+	goto variable;
+
+      if (sym->attr.entry
+	  && (sym->ns == gfc_current_ns
+	      || sym->ns == gfc_current_ns->parent))
+	{
+	  gfc_entry_list *el = NULL;
+	  
+	  for (el = sym->ns->entries; el; el = el->next)
+	    if (sym == el->sym)
+	      goto variable;
+	}
+    }
 
   if (sym->attr.function || sym->attr.external || sym->attr.intrinsic)
     goto function0;
--- gcc/testsuite/gfortran.fortran-torture/execute/entry_10.f90.jj	2005-07-07 13:23:59.000000000 +0200
+++ gcc/testsuite/gfortran.fortran-torture/execute/entry_10.f90	2005-07-07 13:23:22.000000000 +0200
@@ -0,0 +1,13 @@
+	function foo ()
+	foo = 4
+	foo = foo / 2
+	return
+	entry bar ()
+	bar = 9
+	bar = bar / 3
+	end
+
+	program entrytest
+	if (foo () .ne. 2) call abort ()
+	if (bar () .ne. 3) call abort ()
+	end

	Jakub



More information about the Fortran mailing list