aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-12-09 09:17:24 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-12-09 09:17:24 +0000
commit28d08315ed4962e850886887085d35e135d6a34e (patch)
tree20e58b82c3459ec5c5b1e896dcce5b3ad27987fb /gcc/fortran/decl.c
parent4d19dfcf675fcdcb5bd690ef3f67c8daf0f019df (diff)
downloadgcc-28d08315ed4962e850886887085d35e135d6a34e.zip
gcc-28d08315ed4962e850886887085d35e135d6a34e.tar.gz
gcc-28d08315ed4962e850886887085d35e135d6a34e.tar.bz2
re PR fortran/32129 (ICE: Procedure call with array-section-actual to scalar dummy)
2007-12-09 Paul Thomas <pault@gcc.gnu.org> PR fortran/32129 * dump-parse-tree.c (gfc_show_expr_n): New function for debugging. * gfortran.h : Add prototype for gfc_show_expr_n. * expr.c (simplify_constructor): Copy the constructor expression and try to simplify that. If success, replace the original. Otherwise discard the copy, keep going through the structure and return success. PR fortran/31487 * decl.c (build_struct): Pad out default initializers with spaces to the component character length. 2007-12-09 Paul Thomas <pault@gcc.gnu.org> PR fortran/32129 * gfortran.dg/derived_comp_array_ref_6.f90: New test. * gfortran.dg/derived_comp_array_ref_7.f90: New test. PR fortran/31487 * gfortran.dg/char_component_initializer_1.f90: New test. From-SVN: r130719
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index e9b7651..584bb19 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1394,6 +1394,24 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init,
c->dimension = 1;
*as = NULL;
+ /* Should this ever get more complicated, combine with similar section
+ in add_init_expr_to_sym into a separate function. */
+ if (c->ts.type == BT_CHARACTER && !c->pointer && c->initializer)
+ {
+ int len = mpz_get_si (c->ts.cl->length->value.integer);
+
+ if (c->initializer->expr_type == EXPR_CONSTANT)
+ gfc_set_constant_character_len (len, c->initializer, false);
+ else if (mpz_cmp (c->ts.cl->length->value.integer,
+ c->initializer->ts.cl->length->value.integer))
+ {
+ gfc_constructor *ctor = c->initializer->value.constructor;
+ for (;ctor ; ctor = ctor->next)
+ if (ctor->expr->expr_type == EXPR_CONSTANT)
+ gfc_set_constant_character_len (len, ctor->expr, true);
+ }
+ }
+
/* Check array components. */
if (!c->dimension)
{