aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-09-05 13:34:25 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-09-05 13:34:25 +0000
commita99288e554007c0ac5ecfdc7733de19f1a1965dc (patch)
treecec6ce2218b24f0fa23d3e5fe993d76ef4a2d9e7 /gcc/fortran/decl.c
parent8e4bf5c78280d8a41ff53c09e73796fda078c278 (diff)
downloadgcc-a99288e554007c0ac5ecfdc7733de19f1a1965dc.zip
gcc-a99288e554007c0ac5ecfdc7733de19f1a1965dc.tar.gz
gcc-a99288e554007c0ac5ecfdc7733de19f1a1965dc.tar.bz2
re PR fortran/31564 (Error: Type/rank mismatch in argument)
2007-09-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/31564 * primary.c (gfc_match_rvalue): Make expressions that refer to derived type parameters that have array references into variable expressions. Remove references to use association from the symbol. PR fortran/33241 * decl.c (add_init_expr_to_sym): Provide assumed character length parameters with the length of the initialization expression, if a constant, or that of the first element of an array. 2007-09-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/31564 * gfortran.dg/derived_comp_array_ref_2.f90: New test. PR fortran/33241 * gfortran.dg/char_length_10.f90: New test. From-SVN: r128130
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 470cbfa..f9f92ad 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1173,15 +1173,30 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
/* Update symbol character length according initializer. */
if (sym->ts.cl->length == NULL)
{
+ int clen;
/* If there are multiple CHARACTER variables declared on the
same line, we don't want them to share the same length. */
sym->ts.cl = gfc_get_charlen ();
sym->ts.cl->next = gfc_current_ns->cl_list;
gfc_current_ns->cl_list = sym->ts.cl;
- if (sym->attr.flavor == FL_PARAMETER
- && init->expr_type == EXPR_ARRAY)
- sym->ts.cl->length = gfc_copy_expr (init->ts.cl->length);
+ if (sym->attr.flavor == FL_PARAMETER)
+ {
+ if (init->expr_type == EXPR_CONSTANT)
+ {
+ clen = init->value.character.length;
+ sym->ts.cl->length = gfc_int_expr (clen);
+ }
+ else if (init->expr_type == EXPR_ARRAY)
+ {
+ gfc_expr *p = init->value.constructor->expr;
+ clen = p->value.character.length;
+ sym->ts.cl->length = gfc_int_expr (clen);
+ }
+ else if (init->ts.cl && init->ts.cl->length)
+ sym->ts.cl->length =
+ gfc_copy_expr (sym->value->ts.cl->length);
+ }
}
/* Update initializer character length according symbol. */
else if (sym->ts.cl->length->expr_type == EXPR_CONSTANT)