From 1de8a83646644d4486ddceea6a6c102133b8f1be Mon Sep 17 00:00:00 2001 From: Victor Leikehman Date: Sat, 15 May 2004 21:20:09 +0300 Subject: [PATCH] * decl.c (add_init_expr_to_sym): Check for variable size arrays. From-SVN: r81894 --- gcc/fortran/ChangeLog | 4 ++++ gcc/fortran/decl.c | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 549b82daeac..00e6be2f6db 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2004-05-15 Victor Leikehman + + * decl.c (add_init_expr_to_sym): Check for variable size arrays. + 2004-05-15 Tobias Schlueter * primary.c (match_boz_constant): Use gfc_notify_std() for diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 2aed9b248d6..c36c7bad51d 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -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; @@ -287,7 +288,7 @@ add_init_expr_to_sym (const char *name, gfc_expr ** initp, else { /* If a variable appears in a DATA block, it cannot have an - initializer. */ + initializer. */ if (sym->attr.data) { gfc_error @@ -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; -- 2.30.2