| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-Wrealloc-lhs-all -Wrealloc-lhs" } |
| 3 |
! |
| 4 |
! PR fortran/52196 |
| 5 |
! |
| 6 |
implicit none |
| 7 |
type t |
| 8 |
integer :: x |
| 9 |
end type t |
| 10 |
integer, allocatable :: a(:), b |
| 11 |
real, allocatable :: r(:) |
| 12 |
type(t), allocatable :: c(:) |
| 13 |
character(len=:), allocatable :: str |
| 14 |
character(len=:), allocatable :: astr(:) |
| 15 |
|
| 16 |
allocate(a(2), b, c(1)) |
| 17 |
b = 4 ! { dg-warning "Code for reallocating the allocatable variable" } |
| 18 |
a = [b,b] ! { dg-warning "Code for reallocating the allocatable array" } |
| 19 |
c = [t(4)] ! { dg-warning "Code for reallocating the allocatable variable" } |
| 20 |
a = 5 ! no realloc |
| 21 |
c = t(5) ! no realloc |
| 22 |
str = 'abc' ! { dg-warning "Code for reallocating the allocatable variable" } |
| 23 |
astr = 'abc' ! no realloc |
| 24 |
astr = ['abc'] ! { dg-warning "Code for reallocating the allocatable array" } |
| 25 |
a = reshape(a,shape(a)) ! { dg-warning "Code for reallocating the allocatable array" } |
| 26 |
r = sin(r) |
| 27 |
r = sin(r(1)) ! no realloc |
| 28 |
b = sin(r(1)) ! { dg-warning "Code for reallocating the allocatable variable" } |
| 29 |
|
| 30 |
a = nar() ! { dg-warning "Code for reallocating the allocatable array" } |
| 31 |
a = nar2() ! { dg-warning "Code for reallocating the allocatable array" } |
| 32 |
contains |
| 33 |
function nar() |
| 34 |
integer,allocatable :: nar(:) |
| 35 |
end function |
| 36 |
function nar2() |
| 37 |
integer :: nar2(8) |
| 38 |
end function |
| 39 |
end |