OSDN Git Service

2010-04-06 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / alloc_comp_constructor_5.f90
1 ! { dg-do run }
2 ! { dg-options "-fdefault-integer-8" }
3 ! Tests the fix for PR34143, in which the implicit conversion of yy, with
4 ! fdefault-integer-8, would cause a segfault at runtime.
5 !
6 ! Contributed by Thomas Koenig <tkoenig@gcc.gnu.org>
7 !
8 Program test_constructor
9     implicit none
10     type :: thytype
11         integer(4) :: a(2,2)
12     end type thytype
13     type :: mytype
14         integer(4), allocatable :: a(:, :)
15         type(thytype), allocatable :: q(:)
16     end type mytype
17     integer, allocatable :: yy(:,:)
18     type (thytype), allocatable :: bar(:)
19     type (mytype) :: x, y
20     x = mytype(yy, bar)
21     if (allocated (x%a) .or. allocated (x%q)) call abort
22     allocate (yy(2,2))
23     allocate (bar(2))
24     yy = reshape ([10,20,30,40],[2,2])
25     bar = thytype (reshape ([1,2,3,4],[2,2]))
26     ! Check that unallocated allocatables work
27     y = mytype(yy, bar)
28     if (.not.allocated (y%a) .or. .not.allocated (y%q)) call abort
29 end program test_constructor