diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gfortran.dg/class_array_14.f90 | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_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/class_array_14.f90')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gfortran.dg/class_array_14.f90 | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gfortran.dg/class_array_14.f90 b/gcc-4.9/gcc/testsuite/gfortran.dg/class_array_14.f90 new file mode 100644 index 000000000..ad227a907 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gfortran.dg/class_array_14.f90 @@ -0,0 +1,53 @@ +! { dg-do run } +! +! PR fortran/54618 +! +! Check whether default initialization works with INTENT(OUT) +! and ALLOCATABLE and no segfault occurs with OPTIONAL. +! + +subroutine test1() + type typ1 + integer :: i = 6 + end type typ1 + + type(typ1) :: x + + x%i = 77 + call f(x) + if (x%i /= 6) call abort () + call f() +contains + subroutine f(y1) + class(typ1), intent(out), optional :: y1 + end subroutine f +end subroutine test1 + +subroutine test2() + type mytype + end type mytype + type, extends(mytype):: mytype2 + end type mytype2 + + class(mytype), allocatable :: x,y + allocate (mytype2 :: x) + call g(x) + if (allocated (x) .or. .not. same_type_as (x,y)) call abort() + + allocate (mytype2 :: x) + call h(x) + if (allocated (x) .or. .not. same_type_as (x,y)) call abort() + + call h() +contains + subroutine g(y2) + class(mytype), intent(out), allocatable :: y2 + end subroutine g + subroutine h(y3) + class(mytype), optional, intent(out), allocatable :: y3 + end subroutine h +end subroutine test2 + +call test1() +call test2() +end |