This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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;
        }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]