OSDN Git Service

* decl.c (build_struct): Rewrite loop over constructor elements.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Jun 2009 12:53:01 +0000 (12:53 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Jun 2009 12:53:01 +0000 (12:53 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148608 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/decl.c

index 12aa9dc..39bc27f 100644 (file)
@@ -1,3 +1,7 @@
+2009-06-16  Ian Lance Taylor  <iant@google.com>
+
+       * decl.c (build_struct): Rewrite loop over constructor elements.
+
 2009-06-16  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/36947
index 1a4ca36..021392d 100644 (file)
@@ -1435,28 +1435,26 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init,
          bool has_ts;
          gfc_constructor *ctor = c->initializer->value.constructor;
 
-         bool first = true;
-         int first_len;
-
          has_ts = (c->initializer->ts.cl
                    && c->initializer->ts.cl->length_from_typespec);
 
-         for (; ctor; ctor = ctor->next)
+         if (ctor)
            {
-             /* Remember the length of the first element for checking that
-                all elements *in the constructor* have the same length.  This
-                need not be the length of the LHS!  */
-             if (first)
+             int first_len;
+
+             /* Remember the length of the first element for checking
+                that all elements *in the constructor* have the same
+                length.  This need not be the length of the LHS!  */
+             gcc_assert (ctor->expr->expr_type == EXPR_CONSTANT);
+             gcc_assert (ctor->expr->ts.type == BT_CHARACTER);
+             first_len = ctor->expr->value.character.length;
+
+             for (; ctor; ctor = ctor->next)
                {
-                 gcc_assert (ctor->expr->expr_type == EXPR_CONSTANT);
-                 gcc_assert (ctor->expr->ts.type == BT_CHARACTER);
-                 first_len = ctor->expr->value.character.length;
-                 first = false;
+                 if (ctor->expr->expr_type == EXPR_CONSTANT)
+                   gfc_set_constant_character_len (len, ctor->expr,
+                                                   has_ts ? -1 : first_len);
                }
-
-             if (ctor->expr->expr_type == EXPR_CONSTANT)
-               gfc_set_constant_character_len (len, ctor->expr,
-                                               has_ts ? -1 : first_len);
            }
        }
     }