2018-03-15 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / alloc_comp_constructor_5.f90
blobdf62bde0d4b10dd613645cfe5d311cd4e68c40ed
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.
6 ! Contributed by Thomas Koenig <tkoenig@gcc.gnu.org>
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)) STOP 1
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)) STOP 2
29 end program test_constructor