aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2009-06-17 12:53:01 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2009-06-17 12:53:01 +0000
commit2f4d1994d0aee81eb9b6234db264d89d2b7f911a (patch)
tree4dcdf4c7fe0f214e5731fb469276080d1e711c4b /gcc
parent4bc3052992d5a658683fff5136f62924fe18b58a (diff)
downloadgcc-2f4d1994d0aee81eb9b6234db264d89d2b7f911a.zip
gcc-2f4d1994d0aee81eb9b6234db264d89d2b7f911a.tar.gz
gcc-2f4d1994d0aee81eb9b6234db264d89d2b7f911a.tar.bz2
* decl.c (build_struct): Rewrite loop over constructor elements.
From-SVN: r148608
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog4
-rw-r--r--gcc/fortran/decl.c30
2 files changed, 18 insertions, 16 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 12aa9dc..39bc27f 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 1a4ca36..021392d 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -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);
}
}
}