aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f90
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f90
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f90')
-rw-r--r--gcc-4.9/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f9038
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f90 b/gcc-4.9/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f90
new file mode 100644
index 000000000..b2ac4f723
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f90
@@ -0,0 +1,38 @@
+! { dg-do run }
+! { dg-options "-fdefault-integer-8 -O2" }
+! Tests the fix for PR34143, where the implicit type
+! conversion in the derived type constructor would fail,
+! when 'yy' was not allocated. The testscase is an
+! extract from alloc_comp_constructor.f90.
+!
+! Reported by Thomas Koenig <tkoenig@gcc.gnu.org>
+!
+Program test_constructor
+ implicit none
+ type :: thytype
+ integer(4) :: a(2,2)
+ end type thytype
+ type :: mytype
+ integer(4), allocatable :: a(:, :)
+ type(thytype), allocatable :: q(:)
+ end type mytype
+ integer, allocatable :: yy(:,:)
+ type (thytype), allocatable :: bar(:)
+ call non_alloc
+ call alloc
+contains
+ subroutine non_alloc
+ type (mytype) :: x
+ x = mytype(yy, bar)
+ if (allocated (x%a) .or. allocated (x%q)) call abort
+ end subroutine non_alloc
+ subroutine alloc
+ type (mytype) :: x
+ allocate (yy(2,2))
+ allocate (bar(2))
+ yy = reshape ([10,20,30,40],[2,2])
+ bar = thytype (reshape ([1,2,3,4],[2,2]))
+ x = mytype(yy, bar)
+ if (.not.allocated (x%a) .or. .not.allocated (x%q)) call abort
+ end subroutine alloc
+end program test_constructor