This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, fortran] PR29284 - [4.1/4.2 Regression] ICE for optional subroutine argument
- From: Paul Thomas <paulthomas2 at wanadoo dot fr>
- To: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, patch <gcc-patches at gcc dot gnu dot org>, rakuen_himawari at yahoo dot co dot jp
- Date: Sun, 01 Oct 2006 15:43:20 +0200
- Subject: [Patch, fortran] PR29284 - [4.1/4.2 Regression] ICE for optional subroutine argument
:ADDPATCH fortran:
This is an 'obvious' patch and I will apply it tomorrow morning unless
anybody objects.
In testing for an actual argument that is an assumed character length
procedure, I did not test if the expression for the argument is NULL.
This, of course, happens if an optional argument is not present and an
ICE ensues for not doing the check. The testcase is that provided by
the author.
Regtested on Cygwin_NT/AMD64.
Domo arigato-gozaimasu!
Paul
2006-10-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29284
* trans-expr.c (gfc_conv_function_call): Check the expression
is present when testing for the passing of an assumed
character length function.
2006-10-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29284
* gfortran.dg/optional_assumed_charlen_1.f90: New test.
Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c (revision 117052)
--- gcc/fortran/trans-expr.c (working copy)
*************** gfc_conv_function_call (gfc_se * se, gfc
*** 2029,2035 ****
gfc_add_expr_to_block (&se->pre, tmp);
}
! if (fsym && fsym->ts.type == BT_CHARACTER
&& parmse.string_length == NULL_TREE
&& e->ts.type == BT_PROCEDURE
&& e->symtree->n.sym->ts.type == BT_CHARACTER
--- 2029,2035 ----
gfc_add_expr_to_block (&se->pre, tmp);
}
! if (e && fsym && fsym->ts.type == BT_CHARACTER
&& parmse.string_length == NULL_TREE
&& e->ts.type == BT_PROCEDURE
&& e->symtree->n.sym->ts.type == BT_CHARACTER
Index: gcc/testsuite/gfortran.dg/optional_assumed_charlen_1.f90
===================================================================
*** gcc/testsuite/gfortran.dg/optional_assumed_charlen_1.f90 (revision 0)
--- gcc/testsuite/gfortran.dg/optional_assumed_charlen_1.f90 (revision 0)
***************
*** 0 ****
--- 1,20 ----
+ ! { dg-do compile }
+ ! Tests the fix for PR29284 in which an ICE would occur in converting
+ ! the call to a suboutine with an assumed character length, optional
+ ! dummy that is not present.
+ !
+ ! Contributed by Rakuen Himawari <rakuen_himawari@yahoo.co.jp>
+ !
+ MODULE foo
+ CONTAINS
+ SUBROUTINE sub1(a)
+ CHARACTER (LEN=*), OPTIONAL :: a
+ WRITE(*,*) 'foo bar'
+ END SUBROUTINE sub1
+
+ SUBROUTINE sub2
+ CALL sub1()
+ END SUBROUTINE sub2
+
+ END MODULE foo
+ ! { dg-final { cleanup-modules "foo" } }
2006-10-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29284
* trans-expr.c (gfc_conv_function_call): Check the expression
is present when testing for the passing of an assumed
character length function.
2006-10-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29284
* gfortran.dg/optional_assumed_charlen_1.f90: New test.