This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[fortran,patch] Improve checking to fix PR 34083 (ice-on-invalid-code)
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: "fortran at gcc dot gnu dot org List" <fortran at gcc dot gnu dot org>, "gcc-patches list" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 21 Nov 2007 15:05:58 +0000
- Subject: [fortran,patch] Improve checking to fix PR 34083 (ice-on-invalid-code)
The patch below fixes PR 34083, an ice-on-invalid-code issue. In
resolve_structure_cons (resolve.c), we check the rank of the elements
of derived-type constructor, but we didn't take into account the case
where an element is of rank > 0 while it is expected to be a scalar.
This patch does exactly that.
Regtested on x86_64-linux, will come with a testcase. OK to commit?
FX
2007-11-21 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/
* resolve.c (resolve_structure_cons): Also check for zero rank.
Index: resolve.c
===================================================================
--- resolve.c (revision 130330)
+++ resolve.c (working copy)
@@ -742,6 +742,8 @@ resolve_structure_cons (gfc_expr *expr)
for (; comp; comp = comp->next, cons = cons->next)
{
+ int rank;
+
if (!cons->expr)
continue;
@@ -751,14 +753,14 @@ resolve_structure_cons (gfc_expr *expr)
continue;
}
- if (cons->expr->expr_type != EXPR_NULL
- && comp->as && comp->as->rank != cons->expr->rank
+ rank = comp->as ? comp->as->rank : 0;
+ if (cons->expr->expr_type != EXPR_NULL && rank != cons->expr->rank
&& (comp->allocatable || cons->expr->rank))
{
gfc_error ("The rank of the element in the derived type "
"constructor at %L does not match that of the "
"component (%d/%d)", &cons->expr->where,
- cons->expr->rank, comp->as ? comp->as->rank : 0);
+ cons->expr->rank, rank);
t = FAILURE;
}