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_allocate_8.f03 | |
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_allocate_8.f03')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gfortran.dg/class_allocate_8.f03 | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gfortran.dg/class_allocate_8.f03 b/gcc-4.9/gcc/testsuite/gfortran.dg/class_allocate_8.f03 new file mode 100644 index 000000000..1abc55776 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gfortran.dg/class_allocate_8.f03 @@ -0,0 +1,51 @@ +! { dg-do run } +! PR51870 - ALLOCATE with class function expression for SOURCE failed. +! This version of the test allocates class arrays. +! +! Reported by Tobias Burnus <burnus@gcc.gnu.org> +! +module show_producer_class + implicit none + type integrand + integer :: variable = 0 + end type integrand + + type show_producer + contains + procedure ,nopass :: create_show + procedure ,nopass :: create_show_array + end type +contains + function create_show () result(new_integrand) + class(integrand) ,allocatable :: new_integrand + allocate(new_integrand) + new_integrand%variable = -1 + end function + function create_show_array (n) result(new_integrand) + class(integrand) ,allocatable :: new_integrand(:) + integer :: n, i + allocate(new_integrand(n)) + select type (new_integrand) + type is (integrand); new_integrand%variable = [(i, i= 1, n)] + end select + end function +end module + +program main + use show_producer_class + implicit none + class(integrand) ,allocatable :: kernel(:) + type(show_producer) :: executive_producer + + allocate(kernel(5),source=executive_producer%create_show_array (5)) + select type(kernel) + type is (integrand); if (any (kernel%variable .ne. [1,2,3,4,5])) call abort + end select + + deallocate (kernel) + + allocate(kernel(3),source=executive_producer%create_show ()) + select type(kernel) + type is (integrand); if (any (kernel%variable .ne. -1)) call abort + end select +end program |