From f1607c0199cf4c62a27a73d580e5bc25eb46e6ef Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Sun, 25 Nov 2007 22:12:19 +0000 Subject: [PATCH] re PR fortran/33152 (Initialization/declaration problems in block data) 2007-11-25 Jerry DeLisle PR fortran/33152 * decl.c (add_init_expr_to_sym): Remove error message. * resolve.c (check_data_variable): Add new check for a data variable that has an array spec, but no ref and issue an error. * match.c (gfc_match_common): Remove error message. From-SVN: r130415 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/decl.c | 9 --------- gcc/fortran/match.c | 15 --------------- gcc/fortran/resolve.c | 7 +++++++ 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2b4799af88e..f43d26aee00 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2007-11-25 Jerry DeLisle + + PR fortran/33152 + * decl.c (add_init_expr_to_sym): Remove error message. + * resolve.c (check_data_variable): Add new check for a data variable + that has an array spec, but no ref and issue an error. + * match.c (gfc_match_common): Remove error message. + 2007-11-25 Tobias Burnus PR fortran/34079 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index ca17829cb87..d607435668e 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1176,15 +1176,6 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus) return FAILURE; } - if (attr.in_common - && !attr.data - && *initp != NULL) - { - gfc_error ("Initializer not allowed for COMMON variable '%s' at %C", - sym->name); - return FAILURE; - } - if (init == NULL) { /* An initializer is required for PARAMETER declarations. */ diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 83b887372cb..f769651c7f9 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -2783,21 +2783,6 @@ gfc_match_common (void) goto cleanup; } - if (gfc_add_in_common (&sym->attr, sym->name, NULL) == FAILURE) - goto cleanup; - - if (sym->value != NULL && sym->value->expr_type != EXPR_NULL - && (name[0] == '\0' || !sym->attr.data)) - { - if (name[0] == '\0') - gfc_error ("Previously initialized symbol '%s' in " - "blank COMMON block at %C", sym->name); - else - gfc_error ("Previously initialized symbol '%s' in " - "COMMON block '%s' at %C", sym->name, name); - goto cleanup; - } - if (gfc_add_in_common (&sym->attr, sym->name, NULL) == FAILURE) goto cleanup; diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index c6808eb1f21..0fe5d32b6f9 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -8010,6 +8010,13 @@ check_data_variable (gfc_data_variable *var, locus *where) e->symtree->n.sym->name, &e->symtree->n.sym->declared_at); } + if (e->ref == NULL && e->symtree->n.sym->as) + { + gfc_error ("DATA array '%s' at %L must be specified in a previous" + " declaration", e->symtree->n.sym->name, where); + return FAILURE; + } + if (e->rank == 0) { mpz_init_set_ui (size, 1);