aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2018-10-16 23:07:31 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2018-10-16 23:07:31 +0200
commit01982cfbe7e15384db6f9580bd9d05ea867b2adc (patch)
tree529f629473db0373203a9cecaa9c85974f509ad5 /gcc
parentc152593057a3315c3e11343efb2717d5fa8b5df0 (diff)
downloadgcc-01982cfbe7e15384db6f9580bd9d05ea867b2adc.zip
gcc-01982cfbe7e15384db6f9580bd9d05ea867b2adc.tar.gz
gcc-01982cfbe7e15384db6f9580bd9d05ea867b2adc.tar.bz2
Extend source-expr test case
PR fortran/67125 * gfortran.dg/allocate_with_source_26.f90: Extend testcase with polymorphic variables. From-SVN: r265215
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/allocate_with_source_26.f9033
2 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 59bada0..773e570 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,12 @@
2018-10-16 Tobias Burnus <burnus@net-b.de>
PR fortran/67125
+ * gfortran.dg/allocate_with_source_26.f90: Extend
+ testcase with polymorphic variables.
+
+2018-10-16 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/67125
* gfortran.dg/allocate_with_source_26.f90: New.
2018-10-15 David Malcolm <dmalcolm@redhat.com>
diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_26.f90 b/gcc/testsuite/gfortran.dg/allocate_with_source_26.f90
index 38127c0..28f24fc 100644
--- a/gcc/testsuite/gfortran.dg/allocate_with_source_26.f90
+++ b/gcc/testsuite/gfortran.dg/allocate_with_source_26.f90
@@ -11,6 +11,10 @@
program p
implicit none
integer, allocatable :: a(:), b(:), c(:), d(:), e(:)
+ type t
+ integer :: i
+ end type t
+ class(t), allocatable :: p1(:), p2(:), p3(:), p4(:)
integer :: vec(6)
vec = [1,2,3,4,5,6]
@@ -21,6 +25,23 @@ program p
allocate(d, source=[1,2,3,4,5])
allocate(e, source=vec)
+ allocate(p1(3:4))
+ p1(:)%i = [43,56]
+ allocate(p2, source=p1)
+ call do_allocate(p1, size(p1))
+ allocate(p4, source=poly_init())
+
+ if (lbound(p1, 1) /= 3 .or. ubound(p1, 1) /= 4 &
+ .or. lbound(p2, 1) /= 3 .or. ubound(p2, 1) /= 4 &
+ .or. lbound(p3, 1) /= 1 .or. ubound(p3, 1) /= 2 &
+ .or. lbound(p4, 1) /= 7 .or. ubound(p4, 1) /= 8 &
+ .or. p1(3)%i /= 43 .or. p1(4)%i /= 56 &
+ .or. p2(3)%i /= 43 .or. p2(4)%i /= 56 &
+ .or. p3(1)%i /= 43 .or. p3(2)%i /= 56 &
+ .or. p4(7)%i /= 11 .or. p4(8)%i /= 12) then
+ call abort()
+ endif
+
!write(*,*) lbound(a,1), ubound(a,1) ! prints 1 3
!write(*,*) lbound(b,1), ubound(b,1) ! prints 1 3
!write(*,*) lbound(c,1), ubound(c,1) ! prints 3 5
@@ -37,6 +58,18 @@ program p
contains
+ subroutine do_allocate(x, n)
+ integer, value :: n
+ class(t), intent(in) :: x(n)
+ allocate(p3, source=x)
+ end subroutine
+
+ function poly_init()
+ class(t), allocatable :: poly_init(:)
+ allocate(poly_init(7:8))
+ poly_init = [t :: t(11), t(12)]
+ end function poly_init
+
pure function f(i)
integer, intent(in) :: i
integer :: f(i)