diff options
author | Tobias Burnus <burnus@net-b.de> | 2010-06-19 00:23:40 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2010-06-19 00:23:40 +0200 |
commit | ddf58e42fe46db1cf05f21f61fc05f2d2107d5d5 (patch) | |
tree | 21ccfc87d5e4e9a78917b144a93462408315e5f8 /gcc/fortran | |
parent | ca0cb93e349680470ab76b29525e63f6f8dd3ba5 (diff) | |
download | gcc-ddf58e42fe46db1cf05f21f61fc05f2d2107d5d5.zip gcc-ddf58e42fe46db1cf05f21f61fc05f2d2107d5d5.tar.gz gcc-ddf58e42fe46db1cf05f21f61fc05f2d2107d5d5.tar.bz2 |
re PR fortran/44556 (incorrect error: Stat-variable at (1) shall not be DEALLOCATEd within the same DEALLOCATE statement)
2010-06-18 Tobias Burnus <burnus@net-b.de>
PR fortran/44556
* resolve.c (resolve_allocate_deallocate): Properly check
part-refs in stat=/errmsg= for invalid use.
2010-06-18 Tobias Burnus <burnus@net-b.de>
PR fortran/44556
* gfortran.dg/allocate_alloc_opt_11.f90: New.
From-SVN: r161011
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 50 |
2 files changed, 52 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 11bda1f..dfaeeec 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2010-06-18 Tobias Burnus <burnus@net-b.de> + + PR fortran/44556 + * resolve.c (resolve_allocate_deallocate): Properly check + part-refs in stat=/errmsg= for invalid use. + 2010-06-17 Janus Weil <janus@gcc.gnu.org> PR fortran/44558 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 52920f4..0951498 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -6591,8 +6591,29 @@ resolve_allocate_deallocate (gfc_code *code, const char *fcn) for (p = code->ext.alloc.list; p; p = p->next) if (p->expr->symtree->n.sym->name == stat->symtree->n.sym->name) - gfc_error ("Stat-variable at %L shall not be %sd within " - "the same %s statement", &stat->where, fcn, fcn); + { + gfc_ref *ref1, *ref2; + bool found = true; + + for (ref1 = p->expr->ref, ref2 = stat->ref; ref1 && ref2; + ref1 = ref1->next, ref2 = ref2->next) + { + if (ref1->type != REF_COMPONENT || ref2->type != REF_COMPONENT) + continue; + if (ref1->u.c.component->name != ref2->u.c.component->name) + { + found = false; + break; + } + } + + if (found) + { + gfc_error ("Stat-variable at %L shall not be %sd within " + "the same %s statement", &stat->where, fcn, fcn); + break; + } + } } /* Check the errmsg variable. */ @@ -6620,8 +6641,29 @@ resolve_allocate_deallocate (gfc_code *code, const char *fcn) for (p = code->ext.alloc.list; p; p = p->next) if (p->expr->symtree->n.sym->name == errmsg->symtree->n.sym->name) - gfc_error ("Errmsg-variable at %L shall not be %sd within " - "the same %s statement", &errmsg->where, fcn, fcn); + { + gfc_ref *ref1, *ref2; + bool found = true; + + for (ref1 = p->expr->ref, ref2 = errmsg->ref; ref1 && ref2; + ref1 = ref1->next, ref2 = ref2->next) + { + if (ref1->type != REF_COMPONENT || ref2->type != REF_COMPONENT) + continue; + if (ref1->u.c.component->name != ref2->u.c.component->name) + { + found = false; + break; + } + } + + if (found) + { + gfc_error ("Errmsg-variable at %L shall not be %sd within " + "the same %s statement", &errmsg->where, fcn, fcn); + break; + } + } } /* Check that an allocate-object appears only once in the statement. |