| 1 |
! { dg-do compile } |
| 2 |
! { dg-additional-options "-Wsurprising" } |
| 3 |
! |
| 4 |
! PR fortran/51961 - fix checking of MOLD= in ALLOCATE statements |
| 5 |
! |
| 6 |
! Contributed by Tobias Burnus |
| 7 |
|
| 8 |
program p |
| 9 |
implicit none |
| 10 |
type t |
| 11 |
end type t |
| 12 |
type u |
| 13 |
class(t), allocatable :: a(:), b(:,:), c |
| 14 |
end type u |
| 15 |
class(T), allocatable :: a(:), b(:,:), c |
| 16 |
type(u) :: z |
| 17 |
|
| 18 |
allocate (b(2,2)) |
| 19 |
allocate (z% b(2,2)) |
| 20 |
|
| 21 |
allocate (a(2), mold=b(:,1)) |
| 22 |
allocate (a(1:2), mold=b(1,:)) |
| 23 |
allocate (a(2), mold=b) ! { dg-warning "but MOLD= expression at" } |
| 24 |
allocate (a(1:2), mold=b) ! { dg-warning "but MOLD= expression at" } |
| 25 |
allocate (z% a(2), mold=b(:,1)) |
| 26 |
allocate (z% a(1:2), mold=b(1,:)) |
| 27 |
allocate (z% a(2), mold=b) ! { dg-warning "but MOLD= expression at" } |
| 28 |
allocate (z% a(1:2), mold=b) ! { dg-warning "but MOLD= expression at" } |
| 29 |
allocate (z% a(2), mold=z% b(:,1)) |
| 30 |
allocate (z% a(1:2), mold=z% b(1,:)) |
| 31 |
allocate (z% a(2), mold=z% b) ! { dg-warning "but MOLD= expression at" } |
| 32 |
allocate (z% a(1:2), mold=z% b) ! { dg-warning "but MOLD= expression at" } |
| 33 |
|
| 34 |
allocate (c, mold=b(1,1)) |
| 35 |
allocate (c, mold=b) ! { dg-warning "but MOLD= expression at" } |
| 36 |
allocate (z% c, mold=b(1,1)) |
| 37 |
allocate (z% c, mold=b) ! { dg-warning "but MOLD= expression at" } |
| 38 |
allocate (z% c, mold=z% b(1,1)) |
| 39 |
allocate (z% c, mold=z% b) ! { dg-warning "but MOLD= expression at" } |
| 40 |
|
| 41 |
allocate (a, mold=b(:,1)) |
| 42 |
allocate (a, mold=b(1,:)) |
| 43 |
allocate (z% a, mold=b(:,1)) |
| 44 |
allocate (z% a, mold=b(1,:)) |
| 45 |
allocate (z% a, mold=z% b(:,1)) |
| 46 |
allocate (z% a, mold=z% b(1,:)) |
| 47 |
|
| 48 |
allocate (a, mold=b) ! { dg-error "or have the same rank" } |
| 49 |
allocate (z% a, mold=b) ! { dg-error "or have the same rank" } |
| 50 |
allocate (z% a, mold=z% b) ! { dg-error "or have the same rank" } |
| 51 |
end |