This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Fix PR15140: Bogus assertion
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 15 Jul 2004 20:10:46 +0200
- Subject: [gfortran] Fix PR15140: Bogus assertion
In PR 15140 we would hit this assertion in gfc_trans_deferred_vars():
case AS_ASSUMED_SIZE:
/* Must be a dummy parameter. */
assert (sym->attr.dummy);
/* We should always pass assumed size arrays the g77 way. */
assert (TREE_CODE (sym->backend_decl) == PARM_DECL);
fnbody = gfc_trans_g77_array (sym, fnbody);
break;
This assertion is bogus because of the special case outlined in front of
gfc_build_dummy_array_decl:
/* For some dummy arguments we don't use the actual argument directly.
Instead we create a local decl and use that. This allows us to preform
initialization, and construct full type information. */
In that case sym->backend_decl is a VAR_DECL, not a PARM_DECL, and this
is the problem in PR15140. Removing the assertion lets the compiler
continue and generate working code, as I verified, both by looking at
the tree dumps, and by running testcases.
Built and tested on i686-pc-linux. Attached is a testcase that I will
add to the testsuite.
- Tobi
Index: trans-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-decl.c,v
retrieving revision 1.22
diff -u -p -r1.22 trans-decl.c
--- trans-decl.c 12 Jul 2004 01:23:36 -0000 1.22
+++ trans-decl.c 15 Jul 2004 18:01:53 -0000
@@ -1710,7 +1730,6 @@ gfc_trans_deferred_vars (gfc_symbol * pr
assert (sym->attr.dummy);
/* We should always pass assumed size arrays the g77 way. */
- assert (TREE_CODE (sym->backend_decl) == PARM_DECL);
fnbody = gfc_trans_g77_array (sym, fnbody);
break;
! { dg-do run }
! PR 15140: we used to fail an assertion, because we don't use the
! argument of the subroutine directly, but instead use a copy of it.
function M(NAMES)
CHARACTER*(*) NAMES(*)
if (any(names.ne."asdfg")) call abort
m = LEN(NAMES(1))
END function M
character(5) :: c(2)
c = "asdfg"
if(m(c).ne.5) call abort()
end