This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran 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)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=46a5F1+R1vW9eaIDpI0NYYoPVJ237tQeKYDu0h2ypng=; b=L6zmUSvO3QMuFwmM1FR+owm/PKK8udsPhjZKxbwtBil1U9zBqMBy5IIpSYqHspNTgssVz6Cw3+JTGP1e+LK9XNa7ZNF24vh2b3kdaagXk+K53aNATkQ3RQ542QMtynYTkE7kysFantno+vPSPj2nk1pr2E+Nh+4J/UIjewVjP8I=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=H5TyQ3Lojp+1q4nVeh7G1A8eSr9mA+Iaybd9qI+I/NFKiQFL794JrPPpenOp0fNfloke+oDYcO1y7kZ3slKbmBGcB/rYxCe/QVDmBYvHmlTfA1uclI1kt2yY6vhxkkLyoIC2btLjqblWDGhmWa1fSz8ckHbSeYHiRKWM+aIpOtw=
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;
}