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]

Re: [PATCH] Support ENTRY in FUNCTIONs (PR fortran/13082)


On Mon, Apr 11, 2005 at 08:35:34PM +0200, Tobias Schl?ter wrote:
> [tobi@marktplatz tests]$ cat entry3.f90
> function c(a)
> character*5 :: b, c
> c = "HALLO"
> return
> entry b()
> b = "BLUBB"
> return
> end function c
> [tobi@marktplatz tests]$ ~/src/gcc-new/build/gcc/f951 entry.f90
> -fdump-tree-original
>  c
>  b
>  master.0.c
> 
> entry.f90:77: internal compiler error: tree check: expected class
> ?declaration?, have ?constant? (integer_cst) in gfc_add_decl_to_function, at
> fortran/trans-decl.c:151
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://gcc.gnu.org/bugs.html> for instructions.
> 
> (This one really surprised me, given that your testcase for characters works)
> 
> Also you have no testcase for entries with derived type, they do seem to work
> outside of modules, but I'd rather this is tested.  I attached a simple testcase.
> 
> The third bug is a showstopper.  While entries within modules are not as
> important (the usual application of entries seems to be getting module-like
> encapsulation, so there's no point of using them inside modules), we should
> definitely should get them right outside of modules.

Ok, showstoppers are to be solved first... ;)  See patch below.

> For my education: you assume that current_function_namespace is initialized to
> NULL.  Is this a valid assumption?

Yes.  See ISO C99, 6.7.8:
If an object that has static storage duration is not initialized explicitly, then:
-- if it has pointer type, it is initialized to a null pointer;

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

	* trans-decl.c (gfc_generate_function_code): Call
	gfc_conv_const_charlen on BT_CHARACTER result before copying it
	to alternate entry result symbols.

	* gfortran.dg/entry_4.f90: Add some more tests.

--- gcc/fortran/trans-decl.c.jj	2005-04-11 14:39:24.000000000 +0200
+++ gcc/fortran/trans-decl.c	2005-04-11 23:33:14.000000000 +0200
@@ -2331,8 +2331,10 @@ gfc_generate_function_code (gfc_namespac
 	  /* Copy length backend_decls to all entry point result
 	     symbols.  */
 	  gfc_entry_list *el;
-	  tree backend_decl = ns->proc_name->result->ts.cl->backend_decl;
+	  tree backend_decl;
 
+	  gfc_conv_const_charlen (ns->proc_name->ts.cl);
+	  backend_decl = ns->proc_name->result->ts.cl->backend_decl;
 	  for (el = ns->entries; el; el = el->next)
 	    el->sym->result->ts.cl->backend_decl = backend_decl;
 	}
--- gcc/testsuite/gfortran.dg/entry_4.f90.jj	2005-04-11 09:25:45.000000000 +0200
+++ gcc/testsuite/gfortran.dg/entry_4.f90	2005-04-11 23:46:07.000000000 +0200
@@ -14,8 +14,23 @@
 	e2 = str (i:j)
 	end function
 
+	character*5 function f3 ()
+	character e3*(*), e4*(*)
+	integer i
+	f3 = 'ABCDE'
+	return
+	entry e3 (i)
+	entry e4 (i)
+	if (i .gt. 0) then
+	  e3 = 'abcde'
+	else
+	  e4 = 'UVWXY'
+	endif
+	end function
+
 	program entrytest
 	character f1*16, e1*16, e2*16, str*16, ret*16
+	character f3*5, e3*5, e4*5
 	integer i, j
 	str = 'ABCDEFGHIJ'
 	i = 2
@@ -29,4 +44,9 @@
 	ret = e2 (str, i, j)
 	if ((i .ne. 3) .or. (j .ne. 4)) call abort ()
 	if (ret .ne. 'CD') call abort ()
+	if (f3 () .ne. 'ABCDE') call abort ()
+	if (e3 (1) .ne. 'abcde') call abort ()
+	if (e4 (1) .ne. 'abcde') call abort ()
+	if (e3 (0) .ne. 'UVWXY') call abort ()
+	if (e4 (0) .ne. 'UVWXY') call abort ()
 	end program


	Jakub


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