diff options
author | Thomas Koenig <Thomas.Koenig@online.de> | 2006-05-10 18:26:51 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2006-05-10 18:26:51 +0000 |
commit | 3a7e3b6994153f59697d1ab2bc3e251daa63a4d7 (patch) | |
tree | 33ede0b0a98f6e88dc6d67b29051b2c929405f93 /gcc/fortran/trans-array.c | |
parent | 0e2df6898a99a0a0f08ae8439e738049f8134293 (diff) | |
download | gcc-3a7e3b6994153f59697d1ab2bc3e251daa63a4d7.zip gcc-3a7e3b6994153f59697d1ab2bc3e251daa63a4d7.tar.gz gcc-3a7e3b6994153f59697d1ab2bc3e251daa63a4d7.tar.bz2 |
re PR fortran/27470 (wrong memory allocator for derived types)
2005-05-10 Thomas Koenig <Thomas.Koenig@online.de>
PR fortran/27470
* trans-array.c(gfc_array_allocate): If ref->next exists
that is if there is a statement like ALLOCATE(foo%bar(2)),
F95 rules require that bar should be a pointer.
2005-05-10 Thomas Koenig <Thomas.Koenig@online.de>
PR fortran/27470
* gfortran.dg/multiple_allocation_2.f90: New test case.
From-SVN: r113680
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index a620bff..7e9d5a6 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -3068,9 +3068,20 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree pstat) gfc_expr **upper; gfc_ref *ref; int allocatable_array; + int must_be_pointer; ref = expr->ref; + /* In Fortran 95, components can only contain pointers, so that, + in ALLOCATE (foo%bar(2)), bar must be a pointer component. + We test this by checking for ref->next. + An implementation of TR 15581 would need to change this. */ + + if (ref) + must_be_pointer = ref->next != NULL; + else + must_be_pointer = 0; + /* Find the last reference in the chain. */ while (ref && ref->next != NULL) { @@ -3113,7 +3124,10 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree pstat) tmp = gfc_conv_descriptor_data_addr (se->expr); pointer = gfc_evaluate_now (tmp, &se->pre); - allocatable_array = expr->symtree->n.sym->attr.allocatable; + if (must_be_pointer) + allocatable_array = 0; + else + allocatable_array = expr->symtree->n.sym->attr.allocatable; if (TYPE_PRECISION (gfc_array_index_type) == 32) { |