OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gfortran.dg/] [alloc_comp_initializer_1.f90] - Diff between revs 149 and 154

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 149 Rev 154
! { dg-do run }
! { dg-do run }
! This checks the correct functioning of derived types with default initializers
! This checks the correct functioning of derived types with default initializers
! and allocatable components.
! and allocatable components.
!
!
! Contributed by Salvatore Filippone  
! Contributed by Salvatore Filippone  
!
!
module p_type_mod
module p_type_mod
  type m_type
  type m_type
    integer, allocatable :: p(:)
    integer, allocatable :: p(:)
  end type m_type
  end type m_type
  type basep_type
  type basep_type
    type(m_type), allocatable :: av(:)
    type(m_type), allocatable :: av(:)
    type(m_type), pointer :: ap => null ()
    type(m_type), pointer :: ap => null ()
    integer :: i = 101
    integer :: i = 101
  end type basep_type
  end type basep_type
  type p_type
  type p_type
    type(basep_type), allocatable :: basepv(:)
    type(basep_type), allocatable :: basepv(:)
    integer :: p1 , p2 = 1
    integer :: p1 , p2 = 1
  end type p_type
  end type p_type
end module p_type_mod
end module p_type_mod
program foo
program foo
 use p_type_mod
 use p_type_mod
  implicit none
  implicit none
  type(m_type), target :: a
  type(m_type), target :: a
  type(p_type) :: pre
  type(p_type) :: pre
  type(basep_type) :: wee
  type(basep_type) :: wee
  call test_ab8 ()
  call test_ab8 ()
  a = m_type ((/101,102/))
  a = m_type ((/101,102/))
  call p_bld (a, pre)
  call p_bld (a, pre)
  if (associated (wee%ap) .or. wee%i /= 101) call abort ()
  if (associated (wee%ap) .or. wee%i /= 101) call abort ()
  wee%ap => a
  wee%ap => a
  if (.not.associated (wee%ap) .or. allocated (wee%av)) call abort ()
  if (.not.associated (wee%ap) .or. allocated (wee%av)) call abort ()
  wee = basep_type ((/m_type ((/201, 202, 203/))/), null (), 99)
  wee = basep_type ((/m_type ((/201, 202, 203/))/), null (), 99)
  if (.not.allocated (wee%av) .or. associated (wee%ap) .or. (wee%i .ne. 99)) call abort ()
  if (.not.allocated (wee%av) .or. associated (wee%ap) .or. (wee%i .ne. 99)) call abort ()
contains
contains
! Check that allocatable components are nullified after allocation.
! Check that allocatable components are nullified after allocation.
  subroutine test_ab8 ()
  subroutine test_ab8 ()
    type(p_type)    :: p
    type(p_type)    :: p
    integer :: ierr
    integer :: ierr
    if (.not.allocated(p%basepv)) then
    if (.not.allocated(p%basepv)) then
      allocate(p%basepv(1),stat=ierr)
      allocate(p%basepv(1),stat=ierr)
    endif
    endif
    if (allocated (p%basepv) .neqv. .true.) call abort ()
    if (allocated (p%basepv) .neqv. .true.) call abort ()
    if (allocated (p%basepv(1)%av) .neqv. .false.) call abort
    if (allocated (p%basepv(1)%av) .neqv. .false.) call abort
    if (p%basepv(1)%i .ne. 101) call abort ()
    if (p%basepv(1)%i .ne. 101) call abort ()
  end subroutine test_ab8
  end subroutine test_ab8
    subroutine p_bld (a, p)
    subroutine p_bld (a, p)
      use p_type_mod
      use p_type_mod
      type (m_type) :: a
      type (m_type) :: a
      type(p_type) :: p
      type(p_type) :: p
      if (any (a%p .ne. (/101,102/))) call abort ()
      if (any (a%p .ne. (/101,102/))) call abort ()
      if (allocated (p%basepv) .or. (p%p2 .ne. 1)) call abort ()
      if (allocated (p%basepv) .or. (p%p2 .ne. 1)) call abort ()
    end subroutine p_bld
    end subroutine p_bld
end program foo
end program foo
! { dg-final { cleanup-modules "p_type_mod" } }
! { dg-final { cleanup-modules "p_type_mod" } }
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.