! { dg-do run }
|
! { dg-do run }
|
! Checks the fixes for PR34681 and PR34704, in which various mixtures
|
! Checks the fixes for PR34681 and PR34704, in which various mixtures
|
! of default initializer and allocatable array were not being handled
|
! of default initializer and allocatable array were not being handled
|
! correctly for derived types with allocatable components.
|
! correctly for derived types with allocatable components.
|
!
|
!
|
! Contributed by Paolo Giannozzi
|
! Contributed by Paolo Giannozzi
|
!
|
!
|
program boh
|
program boh
|
integer :: c1, c2, c3, c4, c5
|
integer :: c1, c2, c3, c4, c5
|
!
|
!
|
call mah (0, c1) ! These calls deal with PR34681
|
call mah (0, c1) ! These calls deal with PR34681
|
call mah (1, c2)
|
call mah (1, c2)
|
call mah (2, c3)
|
call mah (2, c3)
|
!
|
!
|
if (c1 /= c2) call abort
|
if (c1 /= c2) call abort
|
if (c1 /= c3) call abort
|
if (c1 /= c3) call abort
|
!
|
!
|
call mah0 (c4) ! These calls deal with PR34704
|
call mah0 (c4) ! These calls deal with PR34704
|
call mah1 (c5)
|
call mah1 (c5)
|
!
|
!
|
if (c4 /= c5) call abort
|
if (c4 /= c5) call abort
|
!
|
!
|
end program boh
|
end program boh
|
!
|
!
|
subroutine mah (i, c)
|
subroutine mah (i, c)
|
!
|
!
|
integer, intent(in) :: i
|
integer, intent(in) :: i
|
integer, intent(OUT) :: c
|
integer, intent(OUT) :: c
|
!
|
!
|
type mix_type
|
type mix_type
|
real(8), allocatable :: a(:)
|
real(8), allocatable :: a(:)
|
complex(8), allocatable :: b(:)
|
complex(8), allocatable :: b(:)
|
end type mix_type
|
end type mix_type
|
type(mix_type), allocatable, save :: t(:)
|
type(mix_type), allocatable, save :: t(:)
|
integer :: j, n=1024
|
integer :: j, n=1024
|
!
|
!
|
if (i==0) then
|
if (i==0) then
|
allocate (t(1))
|
allocate (t(1))
|
allocate (t(1)%a(n))
|
allocate (t(1)%a(n))
|
allocate (t(1)%b(n))
|
allocate (t(1)%b(n))
|
do j=1,n
|
do j=1,n
|
t(1)%a(j) = j
|
t(1)%a(j) = j
|
t(1)%b(j) = n-j
|
t(1)%b(j) = n-j
|
end do
|
end do
|
end if
|
end if
|
c = sum( t(1)%a(:) ) + sum( t(1)%b(:) )
|
c = sum( t(1)%a(:) ) + sum( t(1)%b(:) )
|
if ( i==2) then
|
if ( i==2) then
|
deallocate (t(1)%b)
|
deallocate (t(1)%b)
|
deallocate (t(1)%a)
|
deallocate (t(1)%a)
|
deallocate (t)
|
deallocate (t)
|
end if
|
end if
|
end subroutine mah
|
end subroutine mah
|
|
|
subroutine mah0 (c)
|
subroutine mah0 (c)
|
!
|
!
|
integer, intent(OUT) :: c
|
integer, intent(OUT) :: c
|
type mix_type
|
type mix_type
|
real(8), allocatable :: a(:)
|
real(8), allocatable :: a(:)
|
integer :: n=1023
|
integer :: n=1023
|
end type mix_type
|
end type mix_type
|
type(mix_type) :: t
|
type(mix_type) :: t
|
!
|
!
|
allocate(t%a(1))
|
allocate(t%a(1))
|
t%a=3.1415926
|
t%a=3.1415926
|
c = t%n
|
c = t%n
|
deallocate(t%a)
|
deallocate(t%a)
|
!
|
!
|
end subroutine mah0
|
end subroutine mah0
|
!
|
!
|
subroutine mah1 (c)
|
subroutine mah1 (c)
|
!
|
!
|
integer, intent(OUT) :: c
|
integer, intent(OUT) :: c
|
type mix_type
|
type mix_type
|
real(8), allocatable :: a(:)
|
real(8), allocatable :: a(:)
|
integer :: n=1023
|
integer :: n=1023
|
end type mix_type
|
end type mix_type
|
type(mix_type), save :: t
|
type(mix_type), save :: t
|
!
|
!
|
allocate(t%a(1))
|
allocate(t%a(1))
|
t%a=3.1415926
|
t%a=3.1415926
|
c = t%n
|
c = t%n
|
deallocate(t%a)
|
deallocate(t%a)
|
!
|
!
|
end subroutine mah1
|
end subroutine mah1
|
|
|