This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran] PR34248 - ICE with assumed-length character functions having RESULT(...)
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Thu, 29 Nov 2007 17:17:46 +0100
- Subject: [Patch, Fortran] PR34248 - ICE with assumed-length character functions having RESULT(...)
:ADDPATCH fortran:
gfortran is currently crashing for assumed-length character functions if
"RESULT(variable)" is specified.
The attached patch fixes this. (Actually, only the "sym->ts.cl->length"
is NULL.)
Build and regression tested on x86-64 Linux.
OK for the trunk?
Tobias
PS: Could someone also review the following patch?
http://gcc.gnu.org/ml/gcc-patches/2007-11/msg01062.html
2007-11-29 Tobias Burnus <burnus@net-b.de>
PR fortran/34248
* trans-decl.c (generate_dependency_declarations): Check
for NULL pointers before accessing the string length.
2007-11-29 Tobias Burnus <burnus@net-b.de>
PR fortran/34248
* gfortran.dg/result_in_spec_3.f90: New.
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (revision 130514)
+++ gcc/fortran/trans-decl.c (working copy)
@@ -2924,7 +2924,9 @@ generate_dependency_declarations (gfc_sy
int i;
if (sym->ts.type == BT_CHARACTER
- && sym->ts.cl->length->expr_type != EXPR_CONSTANT)
+ && sym->ts.cl
+ && sym->ts.cl->length
+ && sym->ts.cl->length->expr_type != EXPR_CONSTANT)
generate_expr_decls (sym, sym->ts.cl->length);
if (sym->as && sym->as->rank)
Index: gcc/testsuite/gfortran.dg/result_in_spec_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/result_in_spec_3.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/result_in_spec_3.f90 (revision 0)
@@ -0,0 +1,15 @@
+! { dg-do compile }
+!
+! PR fortran/34248
+!
+! There was an ICE for assumed-length functions
+! if RESULT(...) was used and no value assigned
+! to the result variable.
+!
+character(*) FUNCTION test() RESULT(ctab)
+ ctab = "Hello"
+END function test
+
+FUNCTION test2() RESULT(res)
+ character(*) :: res
+END function test2