Commit 51f824b6 by Erik Edelmann

resolve.c (resolve_ref): Check for ALLOCATABLEs to the right of nonzero rank part references too.

fortran/
2006-11-19  Erik Edelmann  <eedelman@gcc.gnu.org>

        * resolve.c (resolve_ref): Check for ALLOCATABLEs to the right of
        nonzero rank part references too.


testsuite/
2006-11-19  Erik Edelmann  <eedelman@gcc.gnu.org>

        * gfortran.dg/alloc_comp_constraint_5.f90: New.
        * gfortran.dg/alloc_comp_assign_2.f90: Removed invalid code.

From-SVN: r118999
parent 39f87c03
2006-11-19 Erik Edelmann <eedelman@gcc.gnu.org>
* resolve.c (resolve_ref): Check for ALLOCATABLEs to the right of
nonzero rank part references too.
2006-11-19 Francois-Xavier Coudert <coudert@clipper.ens.fr> 2006-11-19 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* module.c (gfc_use_module): Uncomment the ISO_FORTRAN_ENV code. * module.c (gfc_use_module): Uncomment the ISO_FORTRAN_ENV code.
......
...@@ -2797,14 +2797,24 @@ resolve_ref (gfc_expr * expr) ...@@ -2797,14 +2797,24 @@ resolve_ref (gfc_expr * expr)
break; break;
case REF_COMPONENT: case REF_COMPONENT:
if ((current_part_dimension || seen_part_dimension) if (current_part_dimension || seen_part_dimension)
&& ref->u.c.component->pointer)
{ {
gfc_error if (ref->u.c.component->pointer)
("Component to the right of a part reference with nonzero " {
"rank must not have the POINTER attribute at %L", gfc_error
&expr->where); ("Component to the right of a part reference with nonzero "
return FAILURE; "rank must not have the POINTER attribute at %L",
&expr->where);
return FAILURE;
}
else if (ref->u.c.component->allocatable)
{
gfc_error
("Component to the right of a part reference with nonzero "
"rank must not have the ALLOCATABLE attribute at %L",
&expr->where);
return FAILURE;
}
} }
n_components++; n_components++;
......
2006-11-19 Erik Edelmann <eedelman@gcc.gnu.org>
* gfortran.dg/alloc_comp_constraint_5.f90: New.
* gfortran.dg/alloc_comp_assign_2.f90: Removed invalid code.
2006-11-19 Francois-Xavier Coudert <coudert@clipper.ens.fr> 2006-11-19 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* gfortran.dg/use_3.f90: Remove error message. * gfortran.dg/use_3.f90: Remove error message.
...@@ -38,12 +38,6 @@ ...@@ -38,12 +38,6 @@
if (any( (/(((y(k)%at(i)%i(j), j = 1,4), i = 1,2), k = 1,2)/) .ne. & if (any( (/(((y(k)%at(i)%i(j), j = 1,4), i = 1,2), k = 1,2)/) .ne. &
(/0,0,2,1,11,12,6,5,11,12,3,2,9,8,7,6/))) call abort () (/0,0,2,1,11,12,6,5,11,12,3,2,9,8,7,6/))) call abort ()
where (y((2))%at(:)%i(2) > 8)
y(2)%at(:)%i(2) = 77
end where
if (any ((/(((y(k)%at(i)%i(j), j = 1,4), i = 1,2), k = 1,2)/) .ne. &
(/0,0,2,1,11,12,6,5,11,77,3,2,9,8,7,6/))) call abort ()
! Check that temporaries and full array alloctable component assignments ! Check that temporaries and full array alloctable component assignments
! are correctly handled in FORALL. ! are correctly handled in FORALL.
......
! { dg-do compile }
! Check that ALLOCATABLE components aren't allowed to the right of a non-zero
! rank part reference.
program test
implicit none
type :: foo
real, allocatable :: bar(:)
end type foo
type(foo), target :: x(3)
integer :: i
real, pointer :: p(:)
allocate(x(:)%bar(5))! { dg-error "must not have the ALLOCATABLE attribute" }
x(:)%bar(1) = 1.0 ! { dg-error "must not have the ALLOCATABLE attribute" }
p => x(:)%bar(1) ! { dg-error "must not have the ALLOCATABLE attribute" }
end program test
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment