diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-08-27 15:19:26 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2019-08-27 15:19:26 +0000 |
commit | 522f3b741606e806f058efcdf6474f2cdcc56718 (patch) | |
tree | 73bbe6e4ed1d559a032261161b45b7d06167927d /gcc/testsuite/gfortran.dg | |
parent | bd903dd991637c9f6a7d767e1b52c45fe89d55fe (diff) | |
parent | 78b52ce61b320949dc277b5911f8dba81d1ffb40 (diff) |
svn merge -r271960:274943 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-9-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/redhat/gcc-9-branch@274959 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
47 files changed, 785 insertions, 36 deletions
diff --git a/gcc/testsuite/gfortran.dg/allocated_1.f90 b/gcc/testsuite/gfortran.dg/allocated_1.f90 new file mode 100644 index 00000000000..43260c24336 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocated_1.f90 @@ -0,0 +1,24 @@ +! { dg-do run } +program foo + + implicit none + + integer, allocatable :: x + integer, allocatable :: a(:) + + logical a1, a2 + + a1 = allocated(scalar=x) + if (a1 .neqv. .false.) stop 1 + a2 = allocated(array=a) + if (a2 .neqv. .false.) stop 2 + + allocate(x) + allocate(a(2)) + + a1 = allocated(scalar=x) + if (a1 .neqv. .true.) stop 3 + a2 = allocated(array=a) + if (a2 .neqv. .true.) stop 4 + +end program foo diff --git a/gcc/testsuite/gfortran.dg/allocated_2.f90 b/gcc/testsuite/gfortran.dg/allocated_2.f90 new file mode 100644 index 00000000000..0ea186a4d13 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocated_2.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +program foo + + implicit none + + integer, allocatable :: x + integer, allocatable :: a(:) + + logical a1, a2 + + a1 = allocated(scalar=a) ! { dg-error "Scalar entity required" } + a2 = allocated(array=x) ! { dg-error "Array entity required" } + a1 = allocated(scalar=x, array=a) ! { dg-error "Too many arguments" } + a1 = allocated(array=a, scalar=x) ! { dg-error "Too many arguments" } + +end program foo diff --git a/gcc/testsuite/gfortran.dg/deferred_character_33.f90 b/gcc/testsuite/gfortran.dg/deferred_character_33.f90 new file mode 100644 index 00000000000..ec864d83c31 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_33.f90 @@ -0,0 +1,35 @@ +! { dg-do run } +! { dg-additional-sources deferred_character_33a.f90 } +! PR fortran/90744 - this used to pass a wrong length +! to an external function without a prototype. +! Original test case by Tomáš Trnka. +module StringModule + implicit none + +contains + function getstr() + character(:), allocatable :: getstr + + getstr = 'OK' + end function +end module +module TestModule + use StringModule + implicit none + +contains + subroutine DoTest() + if (.false.) then + call convrs('A',getstr()) + else + call convrs('B',getstr()) + end if + end subroutine +end module +program external_char_length + use TestModule + + implicit none + + call DoTest() +end program diff --git a/gcc/testsuite/gfortran.dg/deferred_character_33a.f90 b/gcc/testsuite/gfortran.dg/deferred_character_33a.f90 new file mode 100644 index 00000000000..db117cc0b38 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_33a.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +subroutine convrs(quanty,fromto) + implicit none + + character(*), intent(in) :: quanty,fromto + + if (len(fromto) /= 2) stop 1 + if (fromto /= 'OK') stop 2 +end subroutine diff --git a/gcc/testsuite/gfortran.dg/deferred_character_34.f90 b/gcc/testsuite/gfortran.dg/deferred_character_34.f90 new file mode 100644 index 00000000000..20408412879 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_34.f90 @@ -0,0 +1,10 @@ +! { dg-do run } +! PR fortran/90561 +! This used to ICE. +! Original test case by Gerhard Steinmetz. +program p + character(:), allocatable :: z(:) + z = [character(2):: 'ab', 'xy'] + z = z(2) + if (any(z /= 'xy')) stop 1 +end diff --git a/gcc/testsuite/gfortran.dg/do_subscript_3.f90 b/gcc/testsuite/gfortran.dg/do_subscript_3.f90 new file mode 100644 index 00000000000..2f62f58142b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_subscript_3.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! PR fortran/91424 +! Check that only one warning is issued inside blocks, and that +! warnings are also issued for contained subroutines. + +program main + real :: a(5) + block + integer :: j + do j=0, 5 ! { dg-warning "out of bounds" } + a(j) = 2. ! { dg-warning "out of bounds" } + end do + end block + call x +contains + subroutine x + integer :: i + do i=1,6 ! { dg-warning "out of bounds" } + a(i) = 2. ! { dg-warning "out of bounds" } + end do + end subroutine x +end program main diff --git a/gcc/testsuite/gfortran.dg/do_subscript_4.f90 b/gcc/testsuite/gfortran.dg/do_subscript_4.f90 new file mode 100644 index 00000000000..c773fe75aff --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_subscript_4.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR 91424 - this used to warn although the DO loop is zero trip. +program main + implicit none + integer :: i + real :: a(2) + do i=1,3,-1 + a(i) = 2. + end do + print *,a +end program main diff --git a/gcc/testsuite/gfortran.dg/do_subscript_5.f90 b/gcc/testsuite/gfortran.dg/do_subscript_5.f90 new file mode 100644 index 00000000000..54a4f1ba51a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_subscript_5.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! { dg-additional-options "-Wdo-subscript" } +! PR 90563 - this used to be rejected, wrongly +! Original test case by Tobias Neumann +program test + implicit none + integer, parameter :: swap(4) = [2,1,3,4] + real :: p(20) + integer :: j + + p = 0.0 + + ! The following warnings are actually bogus, but we are not yet + ! clever enough to suppress them. + do j=1,6 ! { dg-warning "out of bounds" } + if (j<5) then + p(j) = p(swap(j)) ! { dg-warning "out of bounds" } + endif + enddo +end program diff --git a/gcc/testsuite/gfortran.dg/external_procedure_4.f90 b/gcc/testsuite/gfortran.dg/external_procedure_4.f90 new file mode 100644 index 00000000000..403f1732e26 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/external_procedure_4.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! PR fortran/90937 - this used to cause an ICE. +! Original test case by Toon Moene. +subroutine lfidiff + + implicit none + + contains + + subroutine grlfi(cdnom) + + character(len=*) cdnom(:) + character(len=len(cdnom)) clnoma + + call lficas(clnoma) + + end subroutine grlfi + +end subroutine lfidiff diff --git a/gcc/testsuite/gfortran.dg/initialization_14.f90 b/gcc/testsuite/gfortran.dg/initialization_14.f90 index 4d5b6856cf0..aa1437719ac 100644 --- a/gcc/testsuite/gfortran.dg/initialization_14.f90 +++ b/gcc/testsuite/gfortran.dg/initialization_14.f90 @@ -3,18 +3,18 @@ ! Dummy arguments are disallowed in initialization expressions in ! elemental functions except as arguments to the intrinsic functions ! BIT_SIZE, KIND, LEN, or to the numeric inquiry functions listed -! in 13.11.8 +! in 13.11.8 F95, likewise not allowed in F2003, now allowed in F2008. MODULE TT INTEGER M CONTAINS ELEMENTAL REAL FUNCTION two(N) INTEGER, INTENT(IN) :: N - INTEGER, DIMENSION(N) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" } + INTEGER, DIMENSION(N) :: scr ! Now valid under F2008 END FUNCTION ELEMENTAL REAL FUNCTION twopointfive(N) INTEGER, INTENT(IN) :: N - INTEGER, DIMENSION(MAX(N,2)) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" } + INTEGER, DIMENSION(MAX(N,2)) :: scr ! Now valid under F2008 end FUNCTION twopointfive REAL FUNCTION three(N) diff --git a/gcc/testsuite/gfortran.dg/initialization_30.f90 b/gcc/testsuite/gfortran.dg/initialization_30.f90 new file mode 100644 index 00000000000..ff8436bc7c9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/initialization_30.f90 @@ -0,0 +1,21 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! PR 20851 +! Dummy arguments are disallowed in initialization expressions in +! elemental functions except as arguments to the intrinsic functions +! BIT_SIZE, KIND, LEN, or to the numeric inquiry functions listed +! in 13.11.8 +MODULE TT +INTEGER M +CONTAINS + ELEMENTAL REAL FUNCTION two(N) + INTEGER, INTENT(IN) :: N + INTEGER, DIMENSION(N) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" } + END FUNCTION + + ELEMENTAL REAL FUNCTION twopointfive(N) + INTEGER, INTENT(IN) :: N + INTEGER, DIMENSION(MAX(N,2)) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" } + end FUNCTION twopointfive +END MODULE +END diff --git a/gcc/testsuite/gfortran.dg/integer_exponentiation_4.f90 b/gcc/testsuite/gfortran.dg/integer_exponentiation_4.f90 index 655f6514c57..b224ef96714 100644 --- a/gcc/testsuite/gfortran.dg/integer_exponentiation_4.f90 +++ b/gcc/testsuite/gfortran.dg/integer_exponentiation_4.f90 @@ -21,10 +21,10 @@ program test print *, (-1)**huge(0_8) print *, (-1)**(-huge(0_8)-1_8) - print *, 2**huge(0) ! { dg-error "Arithmetic overflow" } - print *, 2**huge(0_8) ! { dg-error "Arithmetic overflow" } - print *, (-2)**huge(0) ! { dg-error "Arithmetic overflow" } - print *, (-2)**huge(0_8) ! { dg-error "Arithmetic overflow" } + print *, 2**huge(0) ! { dg-error "Arithmetic overflow|exceeds the range" } + print *, 2**huge(0_8) ! { dg-error "Arithmetic overflow|exceeds the range" } + print *, (-2)**huge(0) ! { dg-error "Arithmetic overflow|exceeds the range" } + print *, (-2)**huge(0_8) ! { dg-error "Arithmetic overflow|exceeds the range" } print *, 2**(-huge(0)-1) print *, 2**(-huge(0_8)-1_8) diff --git a/gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90 b/gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90 index 6069bdf7d37..f16b751b128 100644 --- a/gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90 +++ b/gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90 @@ -67,8 +67,6 @@ program test TEST(3_8,43_8,i8) TEST(-3_8,43_8,i8) - TEST(17_8,int(huge(0_4),kind=8)+1,i8) - !!!!! REAL BASE !!!!! TEST(0.0,-1,r4) TEST(0.0,-huge(0)-1,r4) diff --git a/gcc/testsuite/gfortran.dg/lrshift_1.f90 b/gcc/testsuite/gfortran.dg/lrshift_1.f90 index b0e53794943..d262921e4b1 100644 --- a/gcc/testsuite/gfortran.dg/lrshift_1.f90 +++ b/gcc/testsuite/gfortran.dg/lrshift_1.f90 @@ -10,7 +10,7 @@ program test_rshift_lshift 1, 2, 127, 128, 129, huge(i)/2, huge(i) /) do n = 1, size(i) - do j = -30, 30 + do j = 0, 31 if (lshift(i(n),j) /= c_lshift(i(n),j)) STOP 1 if (rshift(i(n),j) /= c_rshift(i(n),j)) STOP 2 end do diff --git a/gcc/testsuite/gfortran.dg/module_error_1.f90 b/gcc/testsuite/gfortran.dg/module_error_1.f90 index 84decc0a571..1792be6e9fa 100644 --- a/gcc/testsuite/gfortran.dg/module_error_1.f90 +++ b/gcc/testsuite/gfortran.dg/module_error_1.f90 @@ -1,5 +1,5 @@ ! { dg-do compile } ! PR fortran/50627 module kernels - select type (args) ! { dg-error "Unexpected SELECT TYPE" } + select type (args) ! { dg-error "cannot appear in this scope" } end module kernels diff --git a/gcc/testsuite/gfortran.dg/no_range_check_1.f90 b/gcc/testsuite/gfortran.dg/no_range_check_1.f90 index d0bd242bbca..7066e19835c 100644 --- a/gcc/testsuite/gfortran.dg/no_range_check_1.f90 +++ b/gcc/testsuite/gfortran.dg/no_range_check_1.f90 @@ -4,11 +4,8 @@ ! This testcase arose from PR 31262 integer :: a integer(kind=8) :: b - a = -3 b = -huge(b) / 7 - a = a ** 73 b = 7894_8 * b - 78941_8 - if ((-3)**73 /= a) STOP 1 if (7894_8 * (-huge(b) / 7) - 78941_8 /= b) STOP 2 a = 1234789786453123 diff --git a/gcc/testsuite/gfortran.dg/pointer_array_11.f90 b/gcc/testsuite/gfortran.dg/pointer_array_11.f90 new file mode 100644 index 00000000000..11885ae4301 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_array_11.f90 @@ -0,0 +1,90 @@ +! { dg-do run } +! +! Test the fix for PR91077 - both the original test and that in comment #4 of the PR. +! +! Contribute by Ygal Klein <ygalklein@gmail.com> +! +program test + implicit none + call original + call comment_4 +contains + subroutine original + integer, parameter :: length = 9 + real(8), dimension(2) :: a, b + integer :: i + type point + real(8) :: x + end type point + + type stored + type(point), dimension(:), allocatable :: np + end type stored + type(stored), dimension(:), pointer :: std =>null() + allocate(std(1)) + allocate(std(1)%np(length)) + std(1)%np(1)%x = 0.3d0 + std(1)%np(2)%x = 0.3555d0 + std(1)%np(3)%x = 0.26782d0 + std(1)%np(4)%x = 0d0 + std(1)%np(5)%x = 1.555d0 + std(1)%np(6)%x = 7.3d0 + std(1)%np(7)%x = 7.8d0 + std(1)%np(8)%x = 6.3d0 + std(1)%np(9)%x = 5.5d0 +! do i = 1, 2 +! write(*, "('std(1)%np(',i1,')%x = ',1e22.14)") i, std(1)%np(i)%x +! end do +! do i = 1, 2 +! write(*, "('std(1)%np(1:',i1,') = ',9e22.14)") i, std(1)%np(1:i)%x +! end do + a = std(1)%np(1:2)%x + b = [std(1)%np(1)%x, std(1)%np(2)%x] +! print *,a +! print *,b + if (allocated (std(1)%np)) deallocate (std(1)%np) + if (associated (std)) deallocate (std) + if (norm2(a - b) .gt. 1d-3) stop 1 + end subroutine + + subroutine comment_4 + integer, parameter :: length = 2 + real(8), dimension(length) :: a, b + integer :: i + + type point + real(8) :: x + end type point + + type points + type(point), dimension(:), pointer :: np=>null() + end type points + + type stored + integer :: l + type(points), pointer :: nfpoint=>null() + end type stored + + type(stored), dimension(:), pointer :: std=>null() + + + allocate(std(1)) + allocate(std(1)%nfpoint) + allocate(std(1)%nfpoint%np(length)) + std(1)%nfpoint%np(1)%x = 0.3d0 + std(1)%nfpoint%np(2)%x = 0.3555d0 + +! do i = 1, length +! write(*, "('std(1)%nfpoint%np(',i1,')%x = ',1e22.14)") i, std(1)%nfpoint%np(i)%x +! end do +! do i = 1, length +! write(*, "('std(1)%nfpoint%np(1:',i1,')%x = ',2e22.14)") i, std(1)%nfpoint%np(1:i)%x +! end do + a = std(1)%nfpoint%np(1:2)%x + b = [std(1)%nfpoint%np(1)%x, std(1)%nfpoint%np(2)%x] + if (associated (std(1)%nfpoint%np)) deallocate (std(1)%nfpoint%np) + if (associated (std(1)%nfpoint)) deallocate (std(1)%nfpoint) + if (associated (std)) deallocate (std) + if (norm2(a - b) .gt. 1d-3) stop 2 + end subroutine +end program test diff --git a/gcc/testsuite/gfortran.dg/pr68544.f90 b/gcc/testsuite/gfortran.dg/pr68544.f90 new file mode 100644 index 00000000000..3b17e2ab523 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr68544.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! PF fortran/68544 +program p + real x + type t + end type + x = f(t) ! { dg-error "used as an actual argument" } +end +subroutine b + type t + end type + print *, shape(t) ! { dg-error "used as an actual argument" } +end diff --git a/gcc/testsuite/gfortran.dg/pr69398.f90 b/gcc/testsuite/gfortran.dg/pr69398.f90 new file mode 100644 index 00000000000..68637465048 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69398.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/69398 +! Contributed by Gerhard Steinmetz +program p + type t + end type + class(t), allocatable :: z(:) + target :: z(:) ! { dg-error "Duplicate DIMENSION attribute" } + allocate (z(2)) +end + diff --git a/gcc/testsuite/gfortran.dg/pr69499.f90 b/gcc/testsuite/gfortran.dg/pr69499.f90 new file mode 100644 index 00000000000..169c6ced515 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69499.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/69499 +! Contributed by Gerhard Steinmetz. +module m + class(*) :: z ! { dg-error "must be dummy, allocatable or pointer" } + select type (x => z) ! { dg-error "cannot appear in this scope" } +end diff --git a/gcc/testsuite/gfortran.dg/pr70754.f90 b/gcc/testsuite/gfortran.dg/pr70754.f90 index d7e790cc036..593acf917ee 100644 --- a/gcc/testsuite/gfortran.dg/pr70754.f90 +++ b/gcc/testsuite/gfortran.dg/pr70754.f90 @@ -18,12 +18,13 @@ contains integer (ii4), dimension(40,40) :: c integer i, j - do i=1,20 - b(i,j) = 123 * a(i,j) + 34 * a(i,j+1) & - + 34 * a(i,j-1) + a(i+1,j+1) & - + a(i+1,j-1) + a(i-1,j+1) & - + a(i-1,j-1) - c(i,j) = 123 + j = 10 + do i=11,30 + b(i,j) = 123 * a(i,j) + 34 * a(i,j+1) & + + 34 * a(i,j-1) + a(i+1,j+1) & + + a(i+1,j-1) + a(i-1,j+1) & + + a(i-1,j-1) + c(i,j) = 123 end do where ((xyz(:,:,2) /= 0) .and. (c /= 0)) diff --git a/gcc/testsuite/gfortran.dg/pr71649.f90 b/gcc/testsuite/gfortran.dg/pr71649.f90 index f20b7687e6f..c01389acfcf 100644 --- a/gcc/testsuite/gfortran.dg/pr71649.f90 +++ b/gcc/testsuite/gfortran.dg/pr71649.f90 @@ -1,13 +1,13 @@ ! { dg-do compile } ! PR71649 Internal Compiler Error -SUBROUTINE Compiler_Options ( Options, Version, WriteOpt ) - USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! { dg-error "already declared" } +SUBROUTINE Compiler_Options ( Options, Version, WriteOpt ) ! { dg-error "\(1\)" } + USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! { dg-error "conflicts with the" } IMPLICIT NONE CHARACTER (LEN=*), INTENT(OUT) :: Options CHARACTER (LEN=*), INTENT(OUT) :: Version LOGICAL, INTENT(IN), OPTIONAL :: WriteOpt - Version = Compiler_Version() - Options = Compiler_Options() ! { dg-error "Unexpected use of subroutine name" } + Version = Compiler_Version() ! { dg-error "has no IMPLICIT type" } + Options = Compiler_Options() ! { dg-error "Unexpected use of subroutine name" } RETURN END SUBROUTINE Compiler_Options diff --git a/gcc/testsuite/gfortran.dg/pr77632_1.f90 b/gcc/testsuite/gfortran.dg/pr77632_1.f90 new file mode 100644 index 00000000000..13fed5991a6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77632_1.f90 @@ -0,0 +1,7 @@ +! { dg-do run } +program foo + implicit none + real, target :: a + real, pointer :: b => a + if (associated(b, a) .eqv. .false.) stop 1 +end program foo diff --git a/gcc/testsuite/gfortran.dg/pr78719_1.f90 b/gcc/testsuite/gfortran.dg/pr78719_1.f90 new file mode 100644 index 00000000000..f5a99c23eee --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78719_1.f90 @@ -0,0 +1,29 @@ +! { dg-do run } +! PR fortran/78719 +! Code contributed by Gerhard Steinmetz +program p + + type t + integer :: n + end type + + abstract interface + subroutine h + end + end interface + + procedure(h), pointer :: s + + s => f + call s + s => g + call s + + contains + + subroutine f + end + + subroutine g + end +end program p diff --git a/gcc/testsuite/gfortran.dg/pr78719_2.f90 b/gcc/testsuite/gfortran.dg/pr78719_2.f90 new file mode 100644 index 00000000000..59abebedd16 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78719_2.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! PR fortran/78719 +! Code contributed by Gerhard Steinmetz +program p + + type t + integer :: n + end type + + real :: g + + abstract interface + subroutine h + end + end interface + + procedure(h), pointer :: s + + s => f + call s + s => g ! { dg-error "Invalid procedure pointer" } + call s + + contains + + subroutine f + end + + subroutine g ! { dg-error "has an explicit interface" } + end + +end program p ! { dg-error "Syntax error" } diff --git a/gcc/testsuite/gfortran.dg/pr78719_3.f90 b/gcc/testsuite/gfortran.dg/pr78719_3.f90 new file mode 100644 index 00000000000..8e7f6ac9781 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78719_3.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! PR fortran/78719 +! Code contributed by Gerhard Steinmetz +program p + + type t + integer :: n + end type + + class(t) :: g ! { dg-error "must be dummy, allocatable or pointer" } + + abstract interface + subroutine h + end + end interface + + procedure(h), pointer :: s + + s => f + call s + s => g ! { dg-error "Invalid procedure pointer" } + call s + + contains + + subroutine f + end + + subroutine g ! { dg-error "has an explicit interface" } + end + +end program p ! { dg-error "Syntax error" } diff --git a/gcc/testsuite/gfortran.dg/pr78739.f90 b/gcc/testsuite/gfortran.dg/pr78739.f90 new file mode 100644 index 00000000000..4b36b76ab21 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78739.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-options "-w" } +! PR fortran/78739 +! Code contributed Gerhard Steinmetz +function f(n) + f() = n ! { dg-error "conflicts with function name" } +end + +function g() + g(x) = x ! { dg-error "conflicts with function name" } +end + +function a() ! This should cause an error, but cannot be easily detected! + a() = x +end diff --git a/gcc/testsuite/gfortran.dg/pr85687.f90 b/gcc/testsuite/gfortran.dg/pr85687.f90 index 03bc2119364..410b2b2a5cc 100644 --- a/gcc/testsuite/gfortran.dg/pr85687.f90 +++ b/gcc/testsuite/gfortran.dg/pr85687.f90 @@ -4,5 +4,5 @@ program p type t end type - print *, rank(t) ! { dg-error "must be a data object" } + print *, rank(t) ! { dg-error "used as an actual argument" } end diff --git a/gcc/testsuite/gfortran.dg/pr86587.f90 b/gcc/testsuite/gfortran.dg/pr86587.f90 new file mode 100644 index 00000000000..fb213352bb9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr86587.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR fortran/86587 +! Code contirubted by Valentin Clement <valentin.clement at env dot ethz dot ch> +! +module mod1 + use iso_c_binding + type, bind(c), private :: mytype + integer(c_int) :: i1, i2 + end type +end module mod1 + +module mod2 + use iso_c_binding + private + type, bind(c) :: mytype + integer(c_int) :: i1, i2 + end type +end module mod2 diff --git a/gcc/testsuite/gfortran.dg/pr87907.f90 b/gcc/testsuite/gfortran.dg/pr87907.f90 new file mode 100644 index 00000000000..0fe4e5090d2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr87907.f90 @@ -0,0 +1,23 @@ +! { dg-do compile } +! PR fortran/pr87907 +! Original testcase contributed by Gerhard Stienmetz <gscfq at t-online dot de> +module m + interface + module function g(x) result(z) + integer, intent(in) :: x + integer, allocatable :: z + end + end interface +end + +submodule(m) m2 + contains + subroutine g(x) ! { dg-error "mismatch in argument" } + end +end + +program p + use m ! { dg-error "has a type" } + integer :: x = 3 + call g(x) ! { dg-error "which is not consistent with" } +end diff --git a/gcc/testsuite/gfortran.dg/pr87991.f90 b/gcc/testsuite/gfortran.dg/pr87991.f90 new file mode 100644 index 00000000000..435871ec779 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr87991.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-w" } +! PR fortran/87991 +program p + type t + character(:), pointer :: c + end type + type(t) :: x + allocate (character(3) :: x%c) + data x%c /'abc'/ ! { dg-error "has the pointer attribute" } +end diff --git a/gcc/testsuite/gfortran.dg/pr87993.f90 b/gcc/testsuite/gfortran.dg/pr87993.f90 new file mode 100644 index 00000000000..96d353d64f8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr87993.f90 @@ -0,0 +1,8 @@ +! { dg-do run } +! Code contributed by Gerhard Steinmetz <gscfq at t-online dot de> +program p + integer, parameter :: a(2) = 1 + integer, parameter :: b = a%kind + if (any(a /= 1)) stop 1 + if (b /= kind(a)) stop 2 +end diff --git a/gcc/testsuite/gfortran.dg/pr88072.f90 b/gcc/testsuite/gfortran.dg/pr88072.f90 new file mode 100644 index 00000000000..5bc6af498dc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88072.f90 @@ -0,0 +1,30 @@ +! { dg-do compile } +! PR fortran/88072 +! Original code contributed by Andrew Wood <andrew at fluidgravity dot co.uk> +module m1 + + implicit none + + type, abstract, public :: t1 + integer, dimension(:), allocatable :: i + contains + procedure(f1), deferred :: f + end type t1 + + type, extends(t1), public :: t2 ! { dg-error "must be ABSTRACT because" } + contains + procedure :: f => f2 ! { dg-error "mismatch for the overriding" } + end type t2 + + abstract interface + function f1(this) ! { dg-error "must be dummy, allocatable or" } + import + class(t1) :: this + class(t1) :: f1 + end function f1 + end interface + contains + type(t2) function f2(this) + class(t2) :: this + end function f2 +end module m1 diff --git a/gcc/testsuite/gfortran.dg/pr89344.f90 b/gcc/testsuite/gfortran.dg/pr89344.f90 new file mode 100644 index 00000000000..8749071bd25 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89344.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +program demo_setval + call setval(value) + write(*,*)'VALUE=',value + contains + subroutine setval(value) + class(*),intent(in) :: value + select type(value) + type is (integer) + value = 10 ! { dg-error "in variable definition context" } + type is (real) + value = 10.20 ! { dg-error "in variable definition context" } + end select + end subroutine setval +end program demo_setval diff --git a/gcc/testsuite/gfortran.dg/pr89647.f90 b/gcc/testsuite/gfortran.dg/pr89647.f90 new file mode 100644 index 00000000000..1d4dc2d0582 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89647.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! Code contributed by Ian Harvey <ian_harvey at bigpond dot com> + MODULE m1 + IMPLICIT NONE + PUBLIC :: False + PUBLIC :: True + CONTAINS + FUNCTION False() RESULT(b) + LOGICAL :: b + b = .FALSE. + END FUNCTION False + + FUNCTION True() RESULT(b) + LOGICAL :: b + b = .TRUE. + END FUNCTION True + END MODULE m1 + + MODULE m2 + USE m1 + IMPLICIT NONE + TYPE, ABSTRACT :: t_parent + CONTAINS + PROCEDURE(False), DEFERRED, NOPASS :: Binding + END TYPE t_parent + CONTAINS + SUBROUTINE s + TYPE, EXTENDS(t_parent) :: t_extension + CONTAINS + PROCEDURE, NOPASS :: Binding => True + END TYPE t_extension + END SUBROUTINE s + END MODULE m2 diff --git a/gcc/testsuite/gfortran.dg/pr90002.f90 b/gcc/testsuite/gfortran.dg/pr90002.f90 new file mode 100644 index 00000000000..cb993a5d5cc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr90002.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! Contributed by Arseny Solokha <asolokha at gmx dot de> +module pc + integer, dimension(1) :: zw[1:1,1:*] +end module pc diff --git a/gcc/testsuite/gfortran.dg/pr90290.f90 b/gcc/testsuite/gfortran.dg/pr90290.f90 new file mode 100644 index 00000000000..280d7ded0c3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr90290.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +program errorstop + integer :: ec + read *, ec + stop ec ! { dg-error "STOP code at " } +end program diff --git a/gcc/testsuite/gfortran.dg/pr91296.f90 b/gcc/testsuite/gfortran.dg/pr91296.f90 new file mode 100644 index 00000000000..5f7bb0e70d3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91296.f90 @@ -0,0 +1,27 @@ +! { dg-do compile } +! { dg-options "-Waliasing" } +! PR fortran/91296 +! Code contributed by Chinoune Mehdi <chinoune dot medhi at hotmail dot com> +module m + implicit none + integer, parameter :: sp = selected_real_kind(6) + +contains + pure subroutine s(a,b,c) + real(sp), intent(in) :: a, b + real(sp), intent(out) :: c + c = a + b + end subroutine s +end module m + +program test + use m + implicit none + real(sp) :: a + complex(sp) :: c + + c = (1._sp,1._sp) + call s(c%re,c%im,a) ! *** This use to cause an ICE. *** + print*,a + +end program test diff --git a/gcc/testsuite/gfortran.dg/pr91359_1.f b/gcc/testsuite/gfortran.dg/pr91359_1.f new file mode 100644 index 00000000000..82423142e98 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91359_1.f @@ -0,0 +1,17 @@ +! { dg-do run } +! PR fortran/91359 +! Orginal code contributed by Brian T. Carcich <briantcarcich at gmail dot com> +! + logical function zero() + goto 2 +1 return +2 zero = .false. + if (.not.zero) goto 1 + return + end + + program test_zero + logical zero + if (zero()) stop 'FAIL: zero() returned .TRUE.' + stop 'OKAY: zero() returned .FALSE.' + end diff --git a/gcc/testsuite/gfortran.dg/pr91359_2.f b/gcc/testsuite/gfortran.dg/pr91359_2.f new file mode 100644 index 00000000000..7b81a3092b5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91359_2.f @@ -0,0 +1,17 @@ +! { dg-do run } +! PR fortran/91359 +! Orginal code contributed by Brian T. Carcich <briantcarcich at gmail dot com> +! + logical function zero() result(a) + goto 2 +1 return +2 a = .false. + if (.not.a) goto 1 + return + end + + program test_zero + logical zero + if (zero()) stop 'FAIL: zero() returned .TRUE.' + stop 'OKAY: zero() returned .FALSE.' + end diff --git a/gcc/testsuite/gfortran.dg/pr91471.f90 b/gcc/testsuite/gfortran.dg/pr91471.f90 new file mode 100644 index 00000000000..fa798444c1d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91471.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/91471 +! Code contributed by Sameeran Joshi <SameeranJayant dot Joshi at amd dot com> +! +! This invalid code (x(1) is referenced, but never set) caused an ICE due +! to hitting a gfc_internal_error() in primary.c (gfc_variable_attr). The +! fix is to remove that gfc_internal_error(). +! +program dynamic + implicit none + integer, dimension(:), allocatable :: x + allocate(x(1)) + stop x(1) +end program dynamic diff --git a/gcc/testsuite/gfortran.dg/pr91485.f90 b/gcc/testsuite/gfortran.dg/pr91485.f90 new file mode 100644 index 00000000000..a6d06877e85 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91485.f90 @@ -0,0 +1,24 @@ +! { dg-do compile } +module foo + implicit none + interface operator(.x.) + module procedure product + end interface operator(.x.) + contains + function product(x, y) + real, intent(in) :: x, y + real :: product + product = x * y + end function product +end module foo + +module gfcbug155 + implicit none + contains + subroutine print_prod (x, y) + use foo, only : operator(.x.) + implicit none + real :: x, y + print *, x .x. y + end subroutine print_prod +end module gfcbug155 diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_51.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_51.f90 new file mode 100644 index 00000000000..62b5d71e30b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_51.f90 @@ -0,0 +1,38 @@ +! { dg-do run } +! +! Test the fix for PR90786. +! +! Contributed by Andrew benson <abensonca@gmail.com> +! +module f +procedure(c), pointer :: c_ + + type :: s + integer :: i = 42 + end type s + class(s), pointer :: res, tgt + +contains + + function c() + implicit none + class(s), pointer :: c + c => tgt + return + end function c + + subroutine fs() + implicit none + c_ => c ! This used to ICE + return + end subroutine fs + +end module f + + use f + allocate (tgt, source = s(99)) + call fs() + res => c_() + if (res%i .ne. 99) stop 1 + deallocate (tgt) +end diff --git a/gcc/testsuite/gfortran.dg/shiftalr_3.f90 b/gcc/testsuite/gfortran.dg/shiftalr_3.f90 new file mode 100644 index 00000000000..4eb0ba728b3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/shiftalr_3.f90 @@ -0,0 +1,42 @@ +! { dg-do run } +! +! Test shift intrinsics when the SHIFT argument equals BIT_SIZE(arg1). + +program test + implicit none + ! Test compile-time simplifications + if (ishft (-1, 32) /= 0) stop 1 ! 0 -> simplify_shift OK + if (ishft (-1,-32) /= 0) stop 2 ! 0 -> simplify_shift OK + if (shiftl (-1, 32) /= 0) stop 3 ! 0 -> simplify_shift OK + if (shiftr (-1, 32) /= 0) stop 4 ! 0 -> simplify_shift OK + if (shifta (-1, 32) /= -1) stop 5 ! -1 -> simplify_shift OK + if (rshift (-1, 32) /= -1) stop 6 ! -1 -> simplify_shift OK + if (lshift (-1, 32) /= 0) stop 7 ! 0 -> simplify_shift OK + ! Test run-time + call foo (-1) +contains + subroutine foo (n) + integer(4) :: i, j, k, n + integer, parameter :: bb = bit_size (n) + ! Test code generated by gfc_conv_intrinsic_ishft + i = ishft (n, bb) ! Logical (left) shift (Fortran 2008) + j = ishft (n,-bb) ! Logical (right) shift (Fortran 2008) + if (i /= 0) stop 11 + if (j /= 0) stop 12 + ! Test code generated by gfc_conv_intrinsic_shift: + i = shiftl (n, bb) ! Logical left shift (Fortran 2008) + j = shiftr (n, bb) ! Logical right shift (Fortran 2008) + k = shifta (n, bb) ! Arithmetic right shift (Fortran 2008) + if (i /= 0) stop 13 + if (j /= 0) stop 14 + if (k /= -1) stop 15 + i = lshift (n, bb) ! Logical left shift (GNU extension) + j = rshift (n, bb) ! Arithmetic right shift (GNU extension) + if (i /= 0) stop 16 + if (j /= -1) stop 17 + do i = bb-1,bb + if (shifta (n, i) /= -1) stop 18 + if (rshift (n, i) /= -1) stop 19 + end do + end subroutine foo +end program test diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_28.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_28.f90 index b474a243233..a9f67273d5e 100644 --- a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_28.f90 +++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_28.f90 @@ -21,7 +21,7 @@ implicit none type,abstract,extends(c_base) :: c_derived contains - procedure :: f_base => f_derived ! { dg-error "Type mismatch in function result \\(CLASS\\(\\*\\)/CLASS\\(c_base\\)\\)" } + procedure :: f_base => f_derived ! { dg-error "Type mismatch in function result" } end type c_derived contains diff --git a/gcc/testsuite/gfortran.dg/use_15.f90 b/gcc/testsuite/gfortran.dg/use_15.f90 index bd5920aa033..eb5aa87cc8b 100644 --- a/gcc/testsuite/gfortran.dg/use_15.f90 +++ b/gcc/testsuite/gfortran.dg/use_15.f90 @@ -28,8 +28,8 @@ subroutine my_sub2 (a) end subroutine -subroutine my_sub3 (a) - use test_mod2, my_sub3 => my_sub2 ! { dg-error "is also the name of the current program unit" } +subroutine my_sub3 (a) ! { dg-error "\(1\)" } + use test_mod2, my_sub3 => my_sub2 ! { dg-error "conflicts with the rename" } real a print *, a end subroutine diff --git a/gcc/testsuite/gfortran.dg/use_rename_8.f90 b/gcc/testsuite/gfortran.dg/use_rename_8.f90 index ad3ab3977c5..b8b49d7a052 100644 --- a/gcc/testsuite/gfortran.dg/use_rename_8.f90 +++ b/gcc/testsuite/gfortran.dg/use_rename_8.f90 @@ -19,8 +19,8 @@ SUBROUTINE T USE MOO, ONLY: X => B END SUBROUTINE T -SUBROUTINE C - USE MOO, ONLY: C ! { dg-error "is also the name of the current program unit" } +SUBROUTINE C ! { dg-error "\(1\)" } + USE MOO, ONLY: C ! { dg-error "conflicts with the" } END SUBROUTINE C SUBROUTINE D @@ -36,15 +36,15 @@ SUBROUTINE F USE MOO, ONLY: X => F END SUBROUTINE F -SUBROUTINE X - USE MOO, ONLY: X => G ! { dg-error "is also the name of the current program unit" } +SUBROUTINE X ! { dg-error "\(1\)" } + USE MOO, ONLY: X => G ! { dg-error "conflicts with the rename" } END SUBROUTINE X -SUBROUTINE Y - USE MOO, ONLY: Y => H ! { dg-error "is also the name of the current program unit" } +SUBROUTINE Y ! { dg-error "\(1\)" } + USE MOO, ONLY: Y => H ! { dg-error "conflicts with the rename" } END SUBROUTINE Y -SUBROUTINE Z - USE MOO, ONLY: Z => I, Z => I ! { dg-error "is also the name of the current program unit" } +SUBROUTINE Z ! { dg-error "\(1\)" } + USE MOO, ONLY: Z => I, Z => I ! { dg-error "conflicts with the rename" } END SUBROUTINE Z |