This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] assumed shape arrays and entry points
- From: Paul Brook <paul at codesourcery dot com>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 29 Apr 2005 03:26:20 +0100
- Subject: [gfortran] assumed shape arrays and entry points
The attached patch fixes a bogus assert in gfc_conv_expr_present. This is also
used for dummy arguments that may not be present in procedures with multiple
entry points.
Tested on i686-linux
Applied to mainline and 4.0-branch.
Paul
2005-04-29 Paul Brook <paul@codesourcery.com>
* trans-expr.c (gfc_conv_expr_present): Fix broken assert. Update
comment.
testsuite/
* gfortran.dg/entry_3.f90: New test.
Index: fortran/trans-expr.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/trans-expr.c,v
retrieving revision 1.40
diff -u -p -r1.40 trans-expr.c
--- fortran/trans-expr.c 23 Mar 2005 11:09:24 -0000 1.40
+++ fortran/trans-expr.c 29 Apr 2005 01:54:40 -0000
@@ -115,14 +115,15 @@ gfc_make_safe_expr (gfc_se * se)
}
-/* Return an expression which determines if a dummy parameter is present. */
+/* Return an expression which determines if a dummy parameter is present.
+ Also used for arguments to procedures with multiple entry points. */
tree
gfc_conv_expr_present (gfc_symbol * sym)
{
tree decl;
- gcc_assert (sym->attr.dummy && sym->attr.optional);
+ gcc_assert (sym->attr.dummy);
decl = gfc_get_symbol_decl (sym);
if (TREE_CODE (decl) != PARM_DECL)
Index: testsuite/gfortran.dg/entry_3.f90
===================================================================
RCS file: testsuite/gfortran.dg/entry_3.f90
diff -N testsuite/gfortran.dg/entry_3.f90
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gfortran.dg/entry_3.f90 29 Apr 2005 02:09:02 -0000
@@ -0,0 +1,25 @@
+! { dg-do run }
+! Test assumed shape arrays in procedures with multiple entry points.
+! Arguments that aren't present in all entry points must be treated like
+! optional arguments.
+module entry_4
+contains
+subroutine foo(a)
+ integer, dimension(:) :: a
+ integer, dimension(:) :: b
+ a = (/1, 2/)
+ return
+entry bar(b)
+ b = (/3, 4/)
+end subroutine
+end module
+
+program entry_4_prog
+ use entry_4
+ integer :: a(2)
+ a = 0
+ call foo(a)
+ if (any (a .ne. (/1, 2/))) call abort
+ call bar(a)
+ if (any (a .ne. (/3, 4/))) call abort
+end program