+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.
+
2006-05-10 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/20460
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)
{
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)
{
+2005-05-10 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR fortran/27470
+ * gfortran.dg/multiple_allocation_2.f90: New test case.
+
2006-05-10 Kazu Hirata <kazu@codesourcery.com>
* gcc.target/arm/pr27387.C: Fix a comment typo.
--- /dev/null
+! { dg-do run }
+! PR 27470: This used fail because of confusion between
+! mol (allocatable) and mol(1)%array(:) (pointer).
+! Derived from a test case by FX Coudert.
+PROGRAM MAIN
+ TYPE foo
+ INTEGER, DIMENSION(:), POINTER :: array
+ END TYPE foo
+
+ type(foo),allocatable,dimension(:) :: mol
+
+ ALLOCATE (mol(1))
+ ALLOCATE (mol(1)%array(5))
+ ALLOCATE (mol(1)%array(5))
+
+ END