* decl.c (add_init_expr_to_sym): Check for variable size arrays.

From-SVN: r81894
This commit is contained in:
Victor Leikehman 2004-05-15 21:20:09 +03:00 committed by Paul Brook
parent e2bb53e59a
commit 1de8a83646
2 changed files with 19 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2004-05-15 Victor Leikehman <lei@haifasphere.co.il>
* decl.c (add_init_expr_to_sym): Check for variable size arrays.
2004-05-15 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* primary.c (match_boz_constant): Use gfc_notify_std() for

View File

@ -254,6 +254,7 @@ static try
add_init_expr_to_sym (const char *name, gfc_expr ** initp,
locus * var_locus)
{
int i;
symbol_attribute attr;
gfc_symbol *sym;
gfc_expr *init;
@ -301,6 +302,19 @@ add_init_expr_to_sym (const char *name, gfc_expr ** initp,
&& gfc_check_assign_symbol (sym, init) == FAILURE)
return FAILURE;
for (i = 0; i < sym->attr.dimension; i++)
{
if (sym->as->lower[i] == NULL
|| sym->as->lower[i]->expr_type != EXPR_CONSTANT
|| sym->as->upper[i] == NULL
|| sym->as->upper[i]->expr_type != EXPR_CONSTANT)
{
gfc_error ("Array '%s' at %C cannot have initializer",
sym->name);
return FAILURE;
}
}
/* Add initializer. Make sure we keep the ranks sane. */
if (sym->attr.dimension && init->rank == 0)
init->rank = sym->as->rank;