diff options
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
-rw-r--r-- | gcc/testsuite/gfortran.dg/allocate_with_source_25.f90 | 71 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_3.f03 | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_39.f90 | 19 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/class_result_7.f90 | 36 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/class_result_8.f90 | 41 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/class_result_9.f90 | 45 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/generic_35.f90 | 31 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/implied_do_io_6.f90 | 39 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/matmul_19.f90 | 25 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr87117.f90 | 14 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/reassoc_4.f | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/submodule_32.f08 | 62 |
12 files changed, 385 insertions, 2 deletions
diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_25.f90 b/gcc/testsuite/gfortran.dg/allocate_with_source_25.f90 new file mode 100644 index 00000000000..92dc50756d4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_with_source_25.f90 @@ -0,0 +1,71 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! +! Test the fix for PR86481 +! +! Contributed by Rich Townsend <townsend@astro.wisc.edu> +! +program simple_leak + + implicit none + + type, abstract :: foo_t + end type foo_t + + type, extends(foo_t) :: foo_a_t + real(8), allocatable :: a(:) + end type foo_a_t + + type, extends(foo_t) :: bar_t + class(foo_t), allocatable :: f + end type bar_t + + integer, parameter :: N = 2 + integer, parameter :: D = 3 + + type(bar_t) :: b(N) + integer :: i + + do i = 1, N + b(i) = func_bar(D) + end do + + do i = 1, N + deallocate (b(i)%f) + end do + +contains + + function func_bar (D) result (b) + + integer, intent(in) :: D + type(bar_t) :: b + + allocate(b%f, SOURCE=func_foo(D)) + + end function func_bar + + !**** + + function func_foo (D) result (f) + + integer, intent(in) :: D + class(foo_t), allocatable :: f + + allocate(f, SOURCE=func_foo_a(D)) ! Lose one of these for each allocation + + end function func_foo + + !**** + + function func_foo_a (D) result (f) + + integer, intent(in) :: D + type(foo_a_t) :: f + + allocate(f%a(D)) ! Lose one of these for each allocation => N*D*elem_size(f%a) + + end function func_foo_a + +end program simple_leak +! { dg-final { scan-tree-dump-times "\>_final" 6 "original" } } diff --git a/gcc/testsuite/gfortran.dg/associate_3.f03 b/gcc/testsuite/gfortran.dg/associate_3.f03 index 20a375dcfd1..da7bec951d1 100644 --- a/gcc/testsuite/gfortran.dg/associate_3.f03 +++ b/gcc/testsuite/gfortran.dg/associate_3.f03 @@ -13,7 +13,7 @@ PROGRAM main ASSOCIATE (a => 1) 5 ! { dg-error "Junk after ASSOCIATE" } - ASSOCIATE (x =>) ! { dg-error "Expected association" } + ASSOCIATE (x =>) ! { dg-error "Invalid association target" } ASSOCIATE (=> 5) ! { dg-error "Expected association" } diff --git a/gcc/testsuite/gfortran.dg/associate_39.f90 b/gcc/testsuite/gfortran.dg/associate_39.f90 new file mode 100644 index 00000000000..16357c32777 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_39.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! +! PR 86935: Bad locus in ASSOCIATE statement +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +implicit none + +type :: t + real :: r = 0.5 + integer :: i = 3 +end type + +type(t) :: x + +associate (r => x%r, & + i => x%ii) ! { dg-error "Invalid association target" } + +end diff --git a/gcc/testsuite/gfortran.dg/class_result_7.f90 b/gcc/testsuite/gfortran.dg/class_result_7.f90 new file mode 100644 index 00000000000..066da549d6d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_result_7.f90 @@ -0,0 +1,36 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! +! Test the fix for PR80477 +! +! Contributed by Stefano Zaghi <stefano.zaghi@cnr.it> +! +module a_type_m + implicit none + type :: a_type_t + real :: x + endtype +contains + subroutine assign_a_type(lhs, rhs) + type(a_type_t), intent(inout) :: lhs + type(a_type_t), intent(in) :: rhs + lhs%x = rhs%x + end subroutine + + function add_a_type(lhs, rhs) result( res ) + type(a_type_t), intent(in) :: lhs + type(a_type_t), intent(in) :: rhs + class(a_type_t), allocatable :: res + allocate (a_type_t :: res) + res%x = lhs%x + rhs%x + end function +end module + +program polymorphic_operators_memory_leaks + use a_type_m + implicit none + type(a_type_t) :: a = a_type_t(1) , b = a_type_t(2) + call assign_a_type (a, add_a_type(a,b)) ! generated a memory leak +end +! { dg-final { scan-tree-dump-times "builtin_free" 1 "original" } } +! { dg-final { scan-tree-dump-times "builtin_malloc" 1 "original" } } diff --git a/gcc/testsuite/gfortran.dg/class_result_8.f90 b/gcc/testsuite/gfortran.dg/class_result_8.f90 new file mode 100644 index 00000000000..573dd44daad --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_result_8.f90 @@ -0,0 +1,41 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! +! Test the fix for the array version of PR80477 +! +! Contributed by Stefano Zaghi <stefano.zaghi@cnr.it> +! +module a_type_m + implicit none + type :: a_type_t + real :: x + real, allocatable :: y(:) + endtype +contains + subroutine assign_a_type(lhs, rhs) + type(a_type_t), intent(inout) :: lhs + type(a_type_t), intent(in) :: rhs(:) + lhs%x = rhs(1)%x + rhs(2)%x + end subroutine + + function add_a_type(lhs, rhs) result( res ) + type(a_type_t), intent(in) :: lhs + type(a_type_t), intent(in) :: rhs + class(a_type_t), allocatable :: res(:) + allocate (a_type_t :: res(2)) + allocate (res(1)%y(1)) + allocate (res(2)%y(1)) + res(1)%x = lhs%x + res(2)%x = rhs%x + end function +end module + +program polymorphic_operators_memory_leaks + use a_type_m + implicit none + type(a_type_t) :: a = a_type_t(1) , b = a_type_t(2) + call assign_a_type (a, add_a_type(a,b)) + print *, a%x +end +! { dg-final { scan-tree-dump-times "builtin_free" 6 "original" } } +! { dg-final { scan-tree-dump-times "builtin_malloc" 7 "original" } } diff --git a/gcc/testsuite/gfortran.dg/class_result_9.f90 b/gcc/testsuite/gfortran.dg/class_result_9.f90 new file mode 100644 index 00000000000..10bc139aabf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_result_9.f90 @@ -0,0 +1,45 @@ +! { dg-do run } +! +! Test the fix for an additional bug found while fixing PR80477 +! +! Contributed by Paul Thomas <pault@gcc.gnu.org> +! +module a_type_m + implicit none + type :: a_type_t + real :: x + real, allocatable :: y(:) + endtype +contains + subroutine assign_a_type(lhs, rhs) + type(a_type_t), intent(inout) :: lhs + type(a_type_t), intent(in) :: rhs(:) + lhs%x = rhs(1)%x + rhs(2)%x + lhs%y = rhs(1)%y + rhs(2)%y + end subroutine + + function add_a_type(lhs, rhs) result( res ) + type(a_type_t), intent(in) :: lhs + type(a_type_t), intent(in) :: rhs + class(a_type_t), allocatable :: res(:) + allocate (a_type_t :: res(2)) + allocate (res(1)%y(1), source = [10.0]) + allocate (res(2)%y(1), source = [20.0]) + res(1)%x = lhs%x + rhs%x + res(2)%x = rhs%x + rhs%x + end function +end module + +program polymorphic_operators_memory_leaks + use a_type_m + implicit none + type(a_type_t) :: a = a_type_t(1) , b = a_type_t(2) + class(a_type_t), allocatable :: res(:) + + res = add_a_type(a,b) ! Remarkably, this ICEd - found while debugging the PR. + call assign_a_type (a, res) + if (int (res(1)%x + res(2)%x) .ne. int (a%x)) stop 1 + if (int (sum (res(1)%y + res(2)%y)) .ne. int (sum (a%y))) stop 1 + deallocate (a%y) + deallocate (res) +end diff --git a/gcc/testsuite/gfortran.dg/generic_35.f90 b/gcc/testsuite/gfortran.dg/generic_35.f90 new file mode 100644 index 00000000000..24ac270319f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/generic_35.f90 @@ -0,0 +1,31 @@ +! { dg-do compile } +! +! PR 86545: ICE in transfer_expr on invalid WRITE statement +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +module m + + type tString + character(len=:), allocatable :: cs + end type + + interface my_trim + module procedure trim_string + end interface + +contains + + elemental function trim_string(self) result(str) + type(tString) :: str + class(tString), intent(in) :: self + end function + +end module + + +program p + use m + type(tString) :: s + write(*,*) my_trim(s) ! { dg-error "cannot have ALLOCATABLE components" } +end diff --git a/gcc/testsuite/gfortran.dg/implied_do_io_6.f90 b/gcc/testsuite/gfortran.dg/implied_do_io_6.f90 new file mode 100644 index 00000000000..ebc99b234d1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/implied_do_io_6.f90 @@ -0,0 +1,39 @@ +! { dg-do run } +! { dg-options "-ffrontend-optimize" } +! PR 86837 - this was mis-optimized by trying to turn this into an +! array I/O statement. +! Original test case by "Pascal". + +Program read_loop + + implicit none + + integer :: i, j + + ! number of values per column + integer, dimension(3) :: nvalues + data nvalues / 1, 2, 4 / + + ! values in a 1D array + real, dimension(7) :: one_d + data one_d / 1, 11, 12, 21, 22, 23, 24 / + + ! where to store the data back + real, dimension(4, 3) :: two_d + + ! 1 - write our 7 values in one block + open(unit=10, file="loop.dta", form="unformatted") + write(10) one_d + close(unit=10) + + ! 2 - read them back in chosen cells of a 2D array + two_d = -9 + open(unit=10, file="loop.dta", form="unformatted", status='old') + read(10) ((two_d(i,j), i=1,nvalues(j)), j=1,3) + close(unit=10, status='delete') + + ! 4 - print the whole array, just in case + + if (any(reshape(two_d,[12]) /= [1.,-9.,-9.,-9.,11.,12.,-9.,-9.,21.,22.,23.,24.])) call abort + +end Program read_loop diff --git a/gcc/testsuite/gfortran.dg/matmul_19.f90 b/gcc/testsuite/gfortran.dg/matmul_19.f90 new file mode 100644 index 00000000000..c4549240c1f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/matmul_19.f90 @@ -0,0 +1,25 @@ +! { dg-do run } +! { dg-options "-finline-matmul-limit=0" } +! PR 86704 - this used to segfault. + +program testmaticovenasobeni +implicit none + + character(len=10) :: line + write (unit=line,fmt=*) testmatmul(120,1,3) + + contains + + function testmatmul(m,n,o) + integer, intent(in) :: m,n,o + real :: A(n,m),B(n,o),C(m,o) + logical :: testmatmul + + call random_number(A) + call random_number(B) + + C=matmul(transpose(A),B) + testmatmul=.true. + end function + +end program testmaticovenasobeni diff --git a/gcc/testsuite/gfortran.dg/pr87117.f90 b/gcc/testsuite/gfortran.dg/pr87117.f90 new file mode 100644 index 00000000000..afca653d08d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr87117.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-options "-O" } +program p + real(4) :: a, b + integer(4) :: n, m + equivalence (a, n) + a = 1024.0 + m = 8 + a = 1024.0 + b = set_exponent(a, m) + n = 8 + a = f(a, n) + b = set_exponent(a, m) +end diff --git a/gcc/testsuite/gfortran.dg/reassoc_4.f b/gcc/testsuite/gfortran.dg/reassoc_4.f index b155cba768c..07b4affb2a4 100644 --- a/gcc/testsuite/gfortran.dg/reassoc_4.f +++ b/gcc/testsuite/gfortran.dg/reassoc_4.f @@ -1,5 +1,5 @@ ! { dg-do compile } -! { dg-options "-O3 -ffast-math -fdump-tree-reassoc1 --param max-completely-peeled-insns=400" } +! { dg-options "-O3 -ffast-math -fdump-tree-reassoc1 --param max-completely-peeled-insns=200" } ! { dg-additional-options "--param max-completely-peel-times=16" { target spu-*-* } } subroutine anisonl(w,vo,anisox,s,ii1,jj1,weight) integer ii1,jj1,i1,iii1,j1,jjj1,k1,l1,m1,n1 diff --git a/gcc/testsuite/gfortran.dg/submodule_32.f08 b/gcc/testsuite/gfortran.dg/submodule_32.f08 new file mode 100644 index 00000000000..529015b86ec --- /dev/null +++ b/gcc/testsuite/gfortran.dg/submodule_32.f08 @@ -0,0 +1,62 @@ +! { dg-do run } +! +! Test the fix for PR86863, where the Type Bound Procedures were +! not flagged as subroutines thereby causing an error at the call +! statements. +! +! Contributed by Damian Rouson <damian@sourceryinstitute.org> +! +module foo + implicit none + integer :: flag = 0 + type bar + contains + procedure, nopass :: foobar + procedure, nopass :: barfoo + end type +contains + subroutine foobar + flag = 1 + end subroutine + subroutine barfoo + flag = 0 + end subroutine +end module + +module foobartoo + implicit none + interface + module subroutine set(object) + use foo + implicit none + type(bar) object + end subroutine + module subroutine unset(object) + use foo + implicit none + type(bar) object + end subroutine + end interface +contains + module procedure unset + use foo, only : bar + call object%barfoo + end procedure +end module + +submodule(foobartoo) subfoobar +contains + module procedure set + use foo, only : bar + call object%foobar + end procedure +end submodule + + use foo + use foobartoo + type(bar) :: obj + call set(obj) + if (flag .ne. 1) stop 1 + call unset(obj) + if (flag .ne. 0) stop 2 +end |