diff options
author | hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-01 22:22:57 +0000 |
---|---|---|
committer | hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-01 22:22:57 +0000 |
commit | 9e169c4bf36a38689550c059570c57efbf00a6fb (patch) | |
tree | 95e6800f7ac2a49ff7f799d96f04172320e70ac0 /gcc/testsuite/gfortran.dg | |
parent | 6170dfb6edfb7b19f8ae5209b8f948fe0076a4ad (diff) | |
download | gcc-9e169c4bf36a38689550c059570c57efbf00a6fb.tar.gz |
Merged trunk at revision 161680 into branch.vect256
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/vect256@161681 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
73 files changed, 1689 insertions, 20 deletions
diff --git a/gcc/testsuite/gfortran.dg/abstract_type_8.f03 b/gcc/testsuite/gfortran.dg/abstract_type_8.f03 new file mode 100644 index 00000000000..c924abac9af --- /dev/null +++ b/gcc/testsuite/gfortran.dg/abstract_type_8.f03 @@ -0,0 +1,29 @@ +! { dg-do compile } +! +! PR 44616: [OOP] ICE if CLASS(foo) is used before its definition +! +! Contributed by bd satish <bdsatish@gmail.com> + +module factory_pattern +implicit none + +type First_Factory + character(len=20) :: factory_type + class(Connection), pointer :: connection_type + contains +end type First_Factory + +type, abstract :: Connection + contains + procedure(generic_desc), deferred :: description +end type Connection + +abstract interface + subroutine generic_desc(self) + import ! Required, cf. PR 44614 + class(Connection) :: self + end subroutine generic_desc +end interface +end module factory_pattern + +! { dg-final { cleanup-modules "factory_pattern" } } diff --git a/gcc/testsuite/gfortran.dg/actual_rank_check_1.f90 b/gcc/testsuite/gfortran.dg/actual_rank_check_1.f90 new file mode 100644 index 00000000000..7167de4270c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/actual_rank_check_1.f90 @@ -0,0 +1,23 @@ +! { dg-do compile } +! Test the fix for PR40158, where the errro message was not clear about scalars. +! +! Contributed by Tobias Burnus <burnus@gcc.gnu.org> +! + implicit none + integer :: i(4,5),j + i = 0 + call sub1(i) + call sub1(j) ! { dg-error "rank-1 and scalar" } + call sub2(i) ! { dg-error "scalar and rank-2" } + call sub2(j) + print '(5i0)', i +contains + subroutine sub1(i1) + integer :: i1(*) + i1(1) = 2 + end subroutine sub1 + subroutine sub2(i2) + integer :: i2 + i2 = 2 + end subroutine sub2 +end diff --git a/gcc/testsuite/gfortran.dg/aliasing_array_result_1.f90 b/gcc/testsuite/gfortran.dg/aliasing_array_result_1.f90 new file mode 100644 index 00000000000..d8899d2ecf8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/aliasing_array_result_1.f90 @@ -0,0 +1,164 @@ +! { dg-do run } +! Tests the fic for PR44582, where gfortran was found to +! produce an incorrect result when the result of a function +! was aliased by a host or use associated variable, to which +! the function is assigned. In these cases a temporary is +! required in the function assignments. The check has to be +! rather restrictive. Whilst the cases marked below might +! not need temporaries, the TODOs are going to be tough. +! +! Reported by Yin Ma <yin@absoft.com> and +! elaborated by Tobias Burnus <burnus@gcc.gnu.org> +! +module foo + INTEGER, PARAMETER :: ONE = 1 + INTEGER, PARAMETER :: TEN = 10 + INTEGER, PARAMETER :: FIVE = TEN/2 + INTEGER, PARAMETER :: TWO = 2 + integer :: foo_a(ONE) + integer :: check(ONE) = TEN + LOGICAL :: abort_flag = .false. +contains + function foo_f() + integer :: foo_f(ONE) + foo_f = -FIVE + foo_f = foo_a - foo_f + end function foo_f + subroutine bar + foo_a = FIVE +! This aliases 'foo_a' by host association. + foo_a = foo_f () + if (any (foo_a .ne. check)) call myabort (0) + end subroutine bar + subroutine myabort(fl) + integer :: fl + print *, fl + abort_flag = .true. + end subroutine myabort +end module foo + +function h_ext() + use foo + integer :: h_ext(ONE) + h_ext = -FIVE + h_ext = FIVE - h_ext +end function h_ext + +function i_ext() result (h) + use foo + integer :: h(ONE) + h = -FIVE + h = FIVE - h +end function i_ext + +subroutine tobias + use foo + integer :: a(ONE) + a = FIVE + call sub1(a) + if (any (a .ne. check)) call myabort (1) +contains + subroutine sub1(x) + integer :: x(ONE) +! 'x' is aliased by host association in 'f'. + x = f() + end subroutine sub1 + function f() + integer :: f(ONE) + f = ONE + f = a + FIVE + end function f +end subroutine tobias + +program test + use foo + implicit none + common /foo_bar/ c + integer :: a(ONE), b(ONE), c(ONE), d(ONE) + interface + function h_ext() + use foo + integer :: h_ext(ONE) + end function h_ext + end interface + interface + function i_ext() result (h) + use foo + integer :: h(ONE) + end function i_ext + end interface + + a = FIVE +! This aliases 'a' by host association + a = f() + if (any (a .ne. check)) call myabort (2) + a = FIVE + if (any (f() .ne. check)) call myabort (3) + call bar + foo_a = FIVE +! This aliases 'foo_a' by host association. + foo_a = g () + if (any (foo_a .ne. check)) call myabort (4) + a = FIVE + a = h() ! TODO: Needs no temporary + if (any (a .ne. check)) call myabort (5) + a = FIVE + a = i() ! TODO: Needs no temporary + if (any (a .ne. check)) call myabort (6) + a = FIVE + a = h_ext() ! Needs no temporary - was OK + if (any (a .ne. check)) call myabort (15) + a = FIVE + a = i_ext() ! Needs no temporary - was OK + if (any (a .ne. check)) call myabort (16) + c = FIVE +! This aliases 'c' through the common block. + c = j() + if (any (c .ne. check)) call myabort (7) + call aaa + call tobias + if (abort_flag) call abort +contains + function f() + integer :: f(ONE) + f = -FIVE + f = a - f + end function f + function g() + integer :: g(ONE) + g = -FIVE + g = foo_a - g + end function g + function h() + integer :: h(ONE) + h = -FIVE + h = FIVE - h + end function h + function i() result (h) + integer :: h(ONE) + h = -FIVE + h = FIVE - h + end function i + function j() + common /foo_bar/ cc + integer :: j(ONE), cc(ONE) + j = -FIVE + j = cc - j + end function j + subroutine aaa() + d = TEN - TWO +! This aliases 'd' through 'get_d'. + d = bbb() + if (any (d .ne. check)) call myabort (8) + end subroutine aaa + function bbb() + integer :: bbb(ONE) + bbb = TWO + bbb = bbb + get_d() + end function bbb + function get_d() + integer :: get_d(ONE) + get_d = d + end function get_d +end program test +! { dg-final { cleanup-modules "foo" } } diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_class_1.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_class_1.f90 new file mode 100644 index 00000000000..c783f49ff77 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/alloc_comp_class_1.f90 @@ -0,0 +1,33 @@ +! { dg-do run } +! Test the fix for PR43895, in which the dummy 'a' was not +! dereferenced for the deallocation of component 'a', as required +! for INTENT(OUT). +! +! Contributed by Salvatore Filippone <sfilippone@uniroma2.it> +! +module d_mat_mod + type :: base_sparse_mat + end type base_sparse_mat + + type, extends(base_sparse_mat) :: d_base_sparse_mat + integer :: i + end type d_base_sparse_mat + + type :: d_sparse_mat + class(d_base_sparse_mat), allocatable :: a + end type d_sparse_mat +end module d_mat_mod + + use d_mat_mod + type(d_sparse_mat) :: b + allocate (b%a) + b%a%i = 42 + call bug14 (b) + if (allocated (b%a)) call abort +contains + subroutine bug14(a) + implicit none + type(d_sparse_mat), intent(out) :: a + end subroutine bug14 +end +! { dg-final { cleanup-modules "d_mat_mod " } } diff --git a/gcc/testsuite/gfortran.dg/allocate_alloc_opt_10.f90 b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_10.f90 new file mode 100644 index 00000000000..5bccefaaf15 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_10.f90 @@ -0,0 +1,46 @@ +! { dg-do run } +! +! PR 43388: [F2008][OOP] ALLOCATE with MOLD= +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +type :: t1 + integer :: i +end type + +type,extends(t1) :: t2 + integer :: j = 4 +end type + +class(t1),allocatable :: x,y +type(t2) :: z + + +!!! first example (works) + +z%j = 5 +allocate(x,MOLD=z) + +select type (x) +type is (t2) + print *,x%j + if (x%j/=4) call abort +class default + call abort() +end select + + +!!! second example (fails) +!!! FIXME: uncomment once implemented (cf. PR 44541) + +! allocate(y,MOLD=x) +! +! select type (y) +! type is (t2) +! print *,y%j +! if (y%j/=4) call abort +! class default +! call abort() +! end select + +end diff --git a/gcc/testsuite/gfortran.dg/allocate_alloc_opt_11.f90 b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_11.f90 new file mode 100644 index 00000000000..c8c7ac633cd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_11.f90 @@ -0,0 +1,26 @@ +! { dg-do compile } +! +! PR fortran/44556 +! +! Contributed by Jonathan Hogg and Steve Kargl. +! +program oh_my + implicit none + type a + integer, allocatable :: b(:), d(:) + character(len=80) :: err + character(len=80), allocatable :: str(:) + integer :: src + end type a + + integer j + type(a) :: c + c%err = 'ok' + allocate(c%d(1)) + allocate(c%b(2), errmsg=c%err, stat=c%d(1)) ! OK + deallocate(c%b, errmsg=c%err, stat=c%d(1)) ! OK + allocate(c%b(2), errmsg=c%err, stat=c%b(1)) ! { dg-error "the same ALLOCATE statement" } + deallocate(c%b, errmsg=c%err, stat=c%b(1)) ! { dg-error "the same DEALLOCATE statement" } + allocate(c%str(2), errmsg=c%str(1), stat=j) ! { dg-error "the same ALLOCATE statement" } + deallocate(c%str, errmsg=c%str(1), stat=j) ! { dg-error "the same DEALLOCATE statement" } +end program oh_my diff --git a/gcc/testsuite/gfortran.dg/allocate_alloc_opt_7.f90 b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_7.f90 new file mode 100644 index 00000000000..e77f6b7c638 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_7.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! +! PR 44207: ICE with ALLOCATABLE components and SOURCE +! +! Contributed by Hans-Werner Boschmann <boschmann@tp1.physik.uni-siegen.de> + +program ice_prog + +type::ice_type + integer,dimension(:),allocatable::list +end type ice_type + +type(ice_type)::this +integer::dim=10,i + +allocate(this%list(dim),source=[(i,i=1,dim)]) + +end program ice_prog diff --git a/gcc/testsuite/gfortran.dg/allocate_alloc_opt_8.f90 b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_8.f90 new file mode 100644 index 00000000000..39aa3638b46 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_8.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +! PR 43388: [F2008][OOP] ALLOCATE with MOLD= +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +type :: t +end type + +class(t),allocatable :: x +type(t) :: z + +allocate(x,MOLD=z) ! { dg-error "MOLD tag at" } + +end diff --git a/gcc/testsuite/gfortran.dg/allocate_alloc_opt_9.f90 b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_9.f90 new file mode 100644 index 00000000000..e51a7ec868a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_9.f90 @@ -0,0 +1,23 @@ +! { dg-do compile } +! +! PR 43388: [F2008][OOP] ALLOCATE with MOLD= +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +type :: t +end type + +type :: u +end type + +class(t),allocatable :: x +type(t) :: z1,z2 +type(u) :: z3 + +allocate(x,MOLD=z1,MOLD=z2) ! { dg-error "Redundant MOLD tag" } +allocate(x,SOURCE=z1,MOLD=z2) ! { dg-error "conflicts with SOURCE tag" } +allocate(t::x,MOLD=z1) ! { dg-error "conflicts with the typespec" } + +allocate(x,MOLD=z3) ! { dg-error "is type incompatible" } + +end diff --git a/gcc/testsuite/gfortran.dg/array_constructor_23.f b/gcc/testsuite/gfortran.dg/array_constructor_23.f index ac57efc2440..fa0a28a1f17 100644 --- a/gcc/testsuite/gfortran.dg/array_constructor_23.f +++ b/gcc/testsuite/gfortran.dg/array_constructor_23.f @@ -20,7 +20,7 @@ DDA1 = ATAN2 ((/(REAL(J1,KV),J1=1,10)/), $ REAL((/(J1,J1=nf10,nf1,mf1)/), KV)) !fails DDA2 = ATAN2 (DDA, DDA(10:1:-1)) - if (any (DDA1 .ne. DDA2)) call abort () + if (any (DDA1 - DDA2 .gt. epsilon(dval))) call abort () END subroutine FA6077 (nf10,nf1,mf1, ida) @@ -42,7 +42,7 @@ QDA1 = MOD ( 1.1_k*( QDA(1) -5.0_k), P=( QDA -2.5_k)) DO J1 = 1,10 QVAL = MOD(1.1_k*(QDA(1)-5.0_k),P=(QDA(J1)-2.5_k)) - if (qval .ne. qda1(j1)) call abort () + if (qval - qda1(j1) .gt. epsilon(qval)) call abort () ENDDO END diff --git a/gcc/testsuite/gfortran.dg/array_memcpy_3.f90 b/gcc/testsuite/gfortran.dg/array_memcpy_3.f90 index df6bd49ef26..78097308030 100644 --- a/gcc/testsuite/gfortran.dg/array_memcpy_3.f90 +++ b/gcc/testsuite/gfortran.dg/array_memcpy_3.f90 @@ -11,5 +11,5 @@ subroutine bar(x) x = (/ 3, 1, 4, 1 /) end subroutine -! { dg-final { scan-tree-dump-times "memcpy|ref-all" 2 "original" } } +! { dg-final { scan-tree-dump-times "memcpy|(ref-all.*ref-all)" 2 "original" } } ! { dg-final { cleanup-tree-dump "original" } } diff --git a/gcc/testsuite/gfortran.dg/array_memcpy_4.f90 b/gcc/testsuite/gfortran.dg/array_memcpy_4.f90 index 0f8b5cb15b0..9f2279d881c 100644 --- a/gcc/testsuite/gfortran.dg/array_memcpy_4.f90 +++ b/gcc/testsuite/gfortran.dg/array_memcpy_4.f90 @@ -9,5 +9,5 @@ d = s end -! { dg-final { scan-tree-dump-times "d = " 1 "original" } } +! { dg-final { scan-tree-dump-times "MEM.*d\\\] = MEM" 1 "original" } } ! { dg-final { cleanup-tree-dump "original" } } diff --git a/gcc/testsuite/gfortran.dg/associate_1.f03 b/gcc/testsuite/gfortran.dg/associate_1.f03 new file mode 100644 index 00000000000..90579c99ce3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_1.f03 @@ -0,0 +1,49 @@ +! { dg-do run } +! { dg-options "-std=f2003 -fall-intrinsics" } + +! PR fortran/38936 +! Check the basic semantics of the ASSOCIATE construct. + +PROGRAM main + IMPLICIT NONE + REAL :: a, b, c + INTEGER, ALLOCATABLE :: arr(:) + + a = -2.0 + b = 3.0 + c = 4.0 + + ! Simple association to expressions. + ASSOCIATE (r => SQRT (a**2 + b**2 + c**2), t => a + b) + PRINT *, t, a, b + IF (ABS (r - SQRT (4.0 + 9.0 + 16.0)) > 1.0e-3) CALL abort () + IF (ABS (t - a - b) > 1.0e-3) CALL abort () + END ASSOCIATE + + ! TODO: Test association to variables when that is supported. + ! TODO: Test association to derived types. + + ! Test association to arrays. + ! TODO: Enable when working. + !ALLOCATE (arr(3)) + !arr = (/ 1, 2, 3 /) + !ASSOCIATE (doubled => 2 * arr) + ! IF (doubled(1) /= 2 .OR. doubled(2) /= 4 .OR. doubled(3) /= 6) & + ! CALL abort () + !END ASSOCIATE + + ! Named and nested associate. + myname: ASSOCIATE (x => a - b * c) + ASSOCIATE (y => 2.0 * x) + IF (ABS (y - 2.0 * (a - b * c)) > 1.0e-3) CALL abort () + END ASSOCIATE + END ASSOCIATE myname ! Matching end-label. + + ! Correct behaviour when shadowing already existing names. + ASSOCIATE (a => 1 * b, b => 1 * a, x => 1, y => 2) + IF (ABS (a - 3.0) > 1.0e-3 .OR. ABS (b + 2.0) > 1.0e-3) CALL abort () + ASSOCIATE (x => 1 * y, y => 1 * x) + IF (x /= 2 .OR. y /= 1) CALL abort () + END ASSOCIATE + END ASSOCIATE +END PROGRAM main diff --git a/gcc/testsuite/gfortran.dg/associate_2.f95 b/gcc/testsuite/gfortran.dg/associate_2.f95 new file mode 100644 index 00000000000..a41398d7850 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_2.f95 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=f95" } + +! PR fortran/38936 +! Test that F95 rejects ASSOCIATE. + +PROGRAM main + IMPLICIT NONE + + ASSOCIATE (a => 5) ! { dg-error "Fortran 2003" } + END ASSOCIATE +END PROGRAM main diff --git a/gcc/testsuite/gfortran.dg/associate_3.f03 b/gcc/testsuite/gfortran.dg/associate_3.f03 new file mode 100644 index 00000000000..c53bd559fb8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_3.f03 @@ -0,0 +1,41 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } + +! PR fortran/38936 +! Check for errors with ASSOCIATE. + +PROGRAM main + IMPLICIT NONE + + ASSOCIATE ! { dg-error "Expected association list" } + + ASSOCIATE () ! { dg-error "Expected association" } + + ASSOCIATE (a => 1) 5 ! { dg-error "Junk after ASSOCIATE" } + + ASSOCIATE (x =>) ! { dg-error "Expected association" } + + ASSOCIATE (=> 5) ! { dg-error "Expected association" } + + ASSOCIATE (x => 5, ) ! { dg-error "Expected association" } + + myname: ASSOCIATE (a => 1) + END ASSOCIATE ! { dg-error "Expected block name of 'myname'" } + + ASSOCIATE (b => 2) + END ASSOCIATE myname ! { dg-error "Syntax error in END ASSOCIATE" } + + myname2: ASSOCIATE (c => 3) + END ASSOCIATE myname3 ! { dg-error "Expected label 'myname2'" } + + ASSOCIATE (a => 1, b => 2, a => 3) ! { dg-error "Duplicate name 'a'" } + + ASSOCIATE (a => 5) + a = 4 ! { dg-error "variable definition context" } + ENd ASSOCIATE + + ASSOCIATE (a => 5) + INTEGER :: b ! { dg-error "Unexpected data declaration statement" } + END ASSOCIATE +END PROGRAM main ! { dg-error "Expecting END ASSOCIATE" } +! { dg-excess-errors "Unexpected end of file" } diff --git a/gcc/testsuite/gfortran.dg/associate_4.f08 b/gcc/testsuite/gfortran.dg/associate_4.f08 new file mode 100644 index 00000000000..c336af2ab13 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_4.f08 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=f2008 -fcoarray=single" } + +! PR fortran/38936 +! Check for error with coindexed target. + +PROGRAM main + IMPLICIT NONE + INTEGER :: a[*] + + ASSOCIATE (x => a[1]) ! { dg-error "must not be coindexed" } +END PROGRAM main diff --git a/gcc/testsuite/gfortran.dg/associated_target_4.f90 b/gcc/testsuite/gfortran.dg/associated_target_4.f90 new file mode 100644 index 00000000000..24f331785e8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associated_target_4.f90 @@ -0,0 +1,23 @@ +! { dg-do run } +! +! PR 44696: [OOP] ASSOCIATED fails on polymorphic variables +! +! Original test case by Hans-Werner Boschmann <boschmann@tp1.physik.uni-siegen.de> +! Modified by Janus Weil <janus@gcc.gnu.org> + +program rte1 + implicit none + type::node_type + class(node_type),pointer::parent,child + integer::id + end type node_type + class(node_type),pointer::root + allocate(root) + allocate(root%child) + root%child%parent=>root + root%id=1 + root%child%id=2 + print *,root%child%id," is child of ",root%id,":" + print *,root%child%parent%id,root%id + if (.not. associated(root%child%parent,root)) call abort() +end program rte1 diff --git a/gcc/testsuite/gfortran.dg/asynchronous_3.f03 b/gcc/testsuite/gfortran.dg/asynchronous_3.f03 new file mode 100644 index 00000000000..7b83374a6e5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/asynchronous_3.f03 @@ -0,0 +1,15 @@ +! { dg-do "compile" } +! +! PR fortran/44457 - no array-subscript actual argument +! for an asynchronous dummy +! + + integer :: a(10), sect(3) + sect = [1,2,3] + call f(a(sect)) ! { dg-error "incompatible" } + call f(a(::2)) +contains + subroutine f(x) + integer, asynchronous :: x(:) + end subroutine f +end diff --git a/gcc/testsuite/gfortran.dg/atan2_1.f90 b/gcc/testsuite/gfortran.dg/atan2_1.f90 index 1f998a1ccde..65da63cd2d3 100644 --- a/gcc/testsuite/gfortran.dg/atan2_1.f90 +++ b/gcc/testsuite/gfortran.dg/atan2_1.f90 @@ -1,4 +1,5 @@ ! { dg-do run } +! { dg-options "-ffloat-store" } ! ! PR fortran/33197 ! diff --git a/gcc/testsuite/gfortran.dg/btest_1.f90 b/gcc/testsuite/gfortran.dg/btest_1.f90 new file mode 100644 index 00000000000..8a72c314cd5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/btest_1.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +program a + integer :: i = 42 + logical l + l = btest(i, -1) ! { dg-error "must be nonnegative" } + l = btest(i, 65) ! { dg-error "must be less than" } +end program a diff --git a/gcc/testsuite/gfortran.dg/class_23.f03 b/gcc/testsuite/gfortran.dg/class_23.f03 new file mode 100644 index 00000000000..e1e35176294 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_23.f03 @@ -0,0 +1,24 @@ +! { dg-do compile } +! +! PR 42051: [OOP] ICE on array-valued function with CLASS formal argument +! +! Original test case by Damian Rouson <damian@rouson.net> +! Modified by Janus Weil <janus@gcc.gnu.org> + + type grid + end type + +contains + + function return_x(this) result(this_x) + class(grid) :: this + real ,dimension(1) :: this_x + end function + + subroutine output() + type(grid) :: mesh + real ,dimension(1) :: x + x = return_x(mesh) + end subroutine + +end diff --git a/gcc/testsuite/gfortran.dg/class_allocate_2.f03 b/gcc/testsuite/gfortran.dg/class_allocate_2.f03 index 754faa9a9f4..cec05f17a1f 100644 --- a/gcc/testsuite/gfortran.dg/class_allocate_2.f03 +++ b/gcc/testsuite/gfortran.dg/class_allocate_2.f03 @@ -18,6 +18,6 @@ end type t2 class(t), allocatable :: a,c,d type(t2) :: b -allocate(a) ! { dg-error "requires a type-spec or SOURCE" } -allocate(b%t) ! { dg-error "requires a type-spec or SOURCE" } +allocate(a) ! { dg-error "requires a type-spec or source-expr" } +allocate(b%t) ! { dg-error "requires a type-spec or source-expr" } end diff --git a/gcc/testsuite/gfortran.dg/contiguous_1.f90 b/gcc/testsuite/gfortran.dg/contiguous_1.f90 new file mode 100644 index 00000000000..e75c08d8ef4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/contiguous_1.f90 @@ -0,0 +1,177 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! PR fortran/40632 +! +! CONTIGUOUS compile-time tests +! + +! C448: Must be an array with POINTER attribute +type t1 + integer, contiguous :: ca(5) ! { dg-error "Component .ca. at .1. has the CONTIGUOUS" } +end type t1 +type t2 + integer, contiguous, allocatable :: cb(:) ! { dg-error "Component .cb. at .1. has the CONTIGUOUS" } +end type t2 +type t3 + integer, contiguous, pointer :: cc(:) ! OK +end type t3 +type t4 + integer, pointer, contiguous :: cd ! { dg-error "Component .cd. at .1. has the CONTIGUOUS" } +end type t4 +end + +! C530: Must be an array and (a) a POINTER or (b) assumed shape. +subroutine test(x, y) + integer, pointer :: x(:) + integer, intent(in) :: y(:) + contiguous :: x, y + + integer, contiguous :: a(5) ! { dg-error ".a. at .1. has the CONTIGUOUS attribute" } + integer, contiguous, allocatable :: b(:) ! { dg-error ".b. at .1. has the CONTIGUOUS attribute" } + integer, contiguous, pointer :: c(:) ! OK + integer, pointer, contiguous :: d ! { dg-error ".d. at .1. has the CONTIGUOUS attribute" } +end + +! Pointer assignment check: +! If the pointer object has the CONTIGUOUS attribute, the pointer target shall be contiguous. +! Note: This is not compile-time checkable; but F2008, 5.3.7 except in a very few cases. +subroutine ptr_assign() + integer, pointer, contiguous :: ptr1(:) + integer, target :: tgt(5) + ptr1 => tgt +end subroutine + + +! C1239 (R1223) If an actual argument is a nonpointer array that has the ASYNCHRONOUS or VOLATILE +! attribute but is not simply contiguous (6.5.4), and the corresponding dummy argument has either the +! VOLATILE or ASYNCHRONOUS attribute, that dummy argument shall be an assumed-shape array +! that does not have the CONTIGUOUS attribute. + +subroutine C1239 + type t + integer :: e(4) + end type t + type(t), volatile :: f + integer, asynchronous :: a(4), b(4) + integer, volatile :: c(4), d(4) + call test (a,b,c) ! OK + call test (a,b(::2),c) ! { dg-error "array without CONTIGUOUS" } + call test (a(::2),b,c) ! { dg-error "array without CONTIGUOUS" } + + call test (a,b,f%e) ! OK + call test (a,f%e,c) ! OK + call test (f%e,b,c) ! OK + call test (a,b,f%e(::2)) ! OK + call test (a,f%e(::2),c) ! { dg-error "array without CONTIGUOUS" } + call test (f%e(::2),b,c) ! { dg-error "array without CONTIGUOUS" } +contains + subroutine test(u, v, w) + integer, asynchronous :: u(:), v(*) + integer, volatile :: w(:) + contiguous :: u + end subroutine test +end subroutine C1239 + + +! C1240 (R1223) If an actual argument is an array pointer that has the ASYNCHRONOUS or VOLATILE +! attribute but does not have the CONTIGUOUS attribute, and the corresponding dummy argument has +! either the VOLATILE or ASYNCHRONOUS attribute, that dummy argument shall be an array pointer +! or an assumed-shape array that does not have the CONTIGUOUS attribute. + +subroutine C1240 + type t + integer,pointer :: e(:) + end type t + type(t), volatile :: f + integer, pointer, asynchronous :: a(:), b(:) + integer,pointer, volatile :: c(:), d(:) + call test (a,b,c) ! { dg-error "array without CONTIGUOUS" } + call test (a,b(::2),c) ! { dg-error "array without CONTIGUOUS" } + call test (a(::2),b,c) ! { dg-error "array without CONTIGUOUS" } + + call test (a,b,f%e) ! { dg-error "array without CONTIGUOUS" } + call test (a,f%e,c) ! { dg-error "array without CONTIGUOUS" } + call test (f%e,b,c) ! { dg-error "array without CONTIGUOUS" } + call test (a,b,f%e(::2)) ! { dg-error "array without CONTIGUOUS" } + call test (a,f%e(::2),c) ! { dg-error "array without CONTIGUOUS" } + call test (f%e(::2),b,c) ! { dg-error "array without CONTIGUOUS" } + + call test2(a,b) + call test3(a,b) + call test2(c,d) + call test3(c,d) + call test2(f%e,d) + call test3(c,f%e) +contains + subroutine test(u, v, w) + integer, asynchronous :: u(:), v(*) + integer, volatile :: w(:) + contiguous :: u + end subroutine test + subroutine test2(x,y) + integer, asynchronous :: x(:) + integer, volatile :: y(:) + end subroutine test2 + subroutine test3(x,y) + integer, pointer, asynchronous :: x(:) + integer, pointer, volatile :: y(:) + end subroutine test3 +end subroutine C1240 + + + +! 12.5.2.7 Pointer dummy variables +! C1241 The actual argument corresponding to a dummy pointer with the CONTIGUOUS attribute shall be +! simply contiguous (6.5.4). + +subroutine C1241 + integer, pointer, contiguous :: a(:) + integer, pointer :: b(:) + call test(a) + call test(b) ! { dg-error "must be simply contigous" } +contains + subroutine test(x) + integer, pointer, contiguous :: x(:) + end subroutine test +end subroutine C1241 + + +! 12.5.2.8 Coarray dummy variables +! If the dummy argument is an array coarray that has the CONTIGUOUS attribute or is not of assumed shape, +! the corresponding actual argument shall be simply contiguous + +subroutine sect12528(cob) + integer, save :: coa(6)[*] + integer :: cob(:)[*] + + call test(coa) + call test2(coa) + call test3(coa) + + call test(cob) ! { dg-error "must be simply contiguous" } + call test2(cob) ! { dg-error "must be simply contiguous" } + call test3(cob) +contains + subroutine test(x) + integer, contiguous :: x(:)[*] + end subroutine test + subroutine test2(x) + integer :: x(*)[*] + end subroutine test2 + subroutine test3(x) + integer :: x(:)[*] + end subroutine test3 +end subroutine sect12528 + + + +subroutine test34 + implicit none + integer, volatile,pointer :: a(:,:),i + call foo(a(2,2:3:2)) ! { dg-error "must be simply contigous" } +contains + subroutine foo(x) + integer, pointer, contiguous, volatile :: x(:) + end subroutine +end subroutine test34 diff --git a/gcc/testsuite/gfortran.dg/contiguous_2.f90 b/gcc/testsuite/gfortran.dg/contiguous_2.f90 new file mode 100644 index 00000000000..782d23dc7cd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/contiguous_2.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +! PR fortran/40632 +! +! CONTIGUOUS compile-time tests +! + +integer, pointer, contiguous :: a(:) ! { dg-error "Fortran 2008:" } +integer, pointer :: b(:) +contiguous :: b ! { dg-error "Fortran 2008:" } +end diff --git a/gcc/testsuite/gfortran.dg/contiguous_3.f90 b/gcc/testsuite/gfortran.dg/contiguous_3.f90 new file mode 100644 index 00000000000..aac55367a45 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/contiguous_3.f90 @@ -0,0 +1,65 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! +! PR fortran/40632 +! +! CONTIGUOUS compile-time tests: Check that contigous +! works properly. + +subroutine test1(a,b) + integer, pointer, contiguous :: test1_a(:) + call foo(test1_a) + call foo(test1_a(::1)) + call foo(test1_a(::2)) +contains + subroutine foo(b) + integer :: b(*) + end subroutine foo +end subroutine test1 + +! For the first two no pack is done; for the third one, an array descriptor +! (cf. below test3) is created for packing. +! +! { dg-final { scan-tree-dump-times "_internal_pack.*test1_a" 0 "original" } } +! { dg-final { scan-tree-dump-times "_internal_unpack.*test1_a" 0 "original" } } + + +subroutine t2(a1,b1,c2,d2) + integer, pointer, contiguous :: a1(:), b1(:) + integer, pointer :: c2(:), d2(:) + a1 = b1 + c2 = d2 +end subroutine t2 + +! { dg-final { scan-tree-dump-times "= a1->dim.0..stride;" 0 "original" } } +! { dg-final { scan-tree-dump-times "= b1->dim.0..stride;" 0 "original" } } +! { dg-final { scan-tree-dump-times "= c2->dim.0..stride;" 1 "original" } } +! { dg-final { scan-tree-dump-times "= d2->dim.0..stride;" 1 "original" } } + + +subroutine test3() + implicit none + integer :: test3_a(8),i + test3_a = [(i,i=1,8)] + call foo(test3_a(::1)) + call foo(test3_a(::2)) + call bar(test3_a(::1)) + call bar(test3_a(::2)) +contains + subroutine foo(x) + integer, contiguous :: x(:) + print *, x + end subroutine + subroutine bar(x) + integer :: x(:) + print *, x + end subroutine bar +end subroutine test3 + +! Once for test1 (third call), once for test3 (second call) +! { dg-final { scan-tree-dump-times "data = origptr" 1 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_internal_pack .&parm" 2 "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_internal_unpack .&parm" 2 "original" } } + + +! { dg-final { cleanup-tree-dump "original" } } diff --git a/gcc/testsuite/gfortran.dg/data_namelist_conflict.f90 b/gcc/testsuite/gfortran.dg/data_namelist_conflict.f90 new file mode 100644 index 00000000000..b09f167fc7c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/data_namelist_conflict.f90 @@ -0,0 +1,26 @@ +! { dg-do run } +! Problem report: http://gcc.gnu.org/ml/fortran/2010-05/msg00139.html +! +module globals + implicit none + integer j + data j/1/ +end module + +program test + use globals + implicit none + character(len=80) str + integer :: i + data i/0/ + namelist /nl/i,j + open(unit=10,status='scratch') + write(10,nl) + i = 42 + j = 42 + rewind(10) + read(10,nl) + if (i /= 0 .or. j /= 1) call abort + close(10) +end program +! { dg-final { cleanup-modules "globals" } } diff --git a/gcc/testsuite/gfortran.dg/end_subroutine_1.f90 b/gcc/testsuite/gfortran.dg/end_subroutine_1.f90 new file mode 100644 index 00000000000..b42f950546b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/end_subroutine_1.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +! +interface + subroutine foo() + end + integer function bar() + end +end interface +contains + subroutine test() + end + integer function f() + f = 42 + end +end diff --git a/gcc/testsuite/gfortran.dg/end_subroutine_2.f90 b/gcc/testsuite/gfortran.dg/end_subroutine_2.f90 new file mode 100644 index 00000000000..8f2e3d10a13 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/end_subroutine_2.f90 @@ -0,0 +1,24 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +program main +interface + subroutine foo() + end + integer function bar() + end +end interface +contains + subroutine test() + end ! { dg-error "Fortran 2008: END statement instead of END SUBROUTINE" } + end subroutine ! To silence successive errors +end program + +subroutine test2() +contains + integer function f() + f = 42 + end ! { dg-error "Fortran 2008: END statement instead of END FUNCTION" } + end function ! To silence successive errors +end subroutine test2 + diff --git a/gcc/testsuite/gfortran.dg/endfile_2.f90 b/gcc/testsuite/gfortran.dg/endfile_2.f90 index e91e80eb2aa..ee911e89e9e 100644 --- a/gcc/testsuite/gfortran.dg/endfile_2.f90 +++ b/gcc/testsuite/gfortran.dg/endfile_2.f90 @@ -5,7 +5,7 @@ integer i endfile(8) rewind(8) - read(8,end=0023)i + read(8,*,end=0023)i call abort ! should never get here stop 0023 continue diff --git a/gcc/testsuite/gfortran.dg/endfile_3.f90 b/gcc/testsuite/gfortran.dg/endfile_3.f90 new file mode 100644 index 00000000000..0c413145c5d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/endfile_3.f90 @@ -0,0 +1,9 @@ +! { dg-do run } +! pr44477 READ/WRITE not allowed after ENDFILE +!------------------------------------------- + open(10, form='formatted', & + action='write', position='rewind', status="scratch") + endfile(10) + write(10,'(a)') "aa" ! { dg-shouldfail "Cannot perform ENDFILE" } +end + diff --git a/gcc/testsuite/gfortran.dg/endfile_4.f90 b/gcc/testsuite/gfortran.dg/endfile_4.f90 new file mode 100644 index 00000000000..a2462c9f878 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/endfile_4.f90 @@ -0,0 +1,8 @@ +! { dg-do run } +! pr44477 ENDFILE not allowed after ENDFILE +!------------------------------------------- + open(10, form='formatted', & + action='write', position='rewind', status="scratch") + endfile(10) + endfile(10) ! { dg-shouldfail "Cannot perform ENDFILE" } +end diff --git a/gcc/testsuite/gfortran.dg/entry_19.f90 b/gcc/testsuite/gfortran.dg/entry_19.f90 new file mode 100644 index 00000000000..b7b8bfa2f2e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/entry_19.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +! +! +! Entry is obsolete in Fortran 2008 +! +subroutine foo() +entry bar() ! { dg-error "Fortran 2008 obsolescent feature: ENTRY" } +end diff --git a/gcc/testsuite/gfortran.dg/eof_3.f90 b/gcc/testsuite/gfortran.dg/eof_3.f90 index 83d652912bc..f1d5098c77b 100644 --- a/gcc/testsuite/gfortran.dg/eof_3.f90 +++ b/gcc/testsuite/gfortran.dg/eof_3.f90 @@ -4,5 +4,6 @@ program test open(unit=32,status="scratch",access="sequential",form="unformatted") read(32,end=100) 100 continue +backspace(32) write (32) end program test diff --git a/gcc/testsuite/gfortran.dg/generic_23.f03 b/gcc/testsuite/gfortran.dg/generic_23.f03 new file mode 100644 index 00000000000..eab185b483d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/generic_23.f03 @@ -0,0 +1,67 @@ +! { dg-do run } +! Test the fix for PR43945 in which the over-ridding of 'doit' and +! 'getit' in type 'foo2' was missed in the specific binding to 'do' and 'get'. +! +! Contributed by Tobias Burnus <burnus@gcc.gnu.org> +! and reported to clf by Salvatore Filippone <sfilippone@uniroma2.it> +! +module foo_mod + type foo + integer :: i + contains + procedure, pass(a) :: doit + procedure, pass(a) :: getit + generic, public :: do => doit + generic, public :: get => getit + end type foo + private doit,getit +contains + subroutine doit(a) + class(foo) :: a + a%i = 1 + write(*,*) 'FOO%DOIT base version' + end subroutine doit + function getit(a) result(res) + class(foo) :: a + integer :: res + res = a%i + end function getit +end module foo_mod + +module foo2_mod + use foo_mod + type, extends(foo) :: foo2 + integer :: j + contains + procedure, pass(a) :: doit => doit2 + procedure, pass(a) :: getit => getit2 +!!$ generic, public :: do => doit +!!$ generic, public :: get => getit + end type foo2 + private doit2, getit2 + +contains + + subroutine doit2(a) + class(foo2) :: a + a%i = 2 + a%j = 3 + end subroutine doit2 + function getit2(a) result(res) + class(foo2) :: a + integer :: res + res = a%j + end function getit2 +end module foo2_mod + +program testd15 + use foo2_mod + type(foo2) :: af2 + + call af2%do() + if (af2%i .ne. 2) call abort + if (af2%get() .ne. 3) call abort + +end program testd15 + +! { dg-final { cleanup-modules "foo_mod foo2_mod" } } diff --git a/gcc/testsuite/gfortran.dg/gomp/pr44536.f90 b/gcc/testsuite/gfortran.dg/gomp/pr44536.f90 new file mode 100644 index 00000000000..0dc896dccea --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr44536.f90 @@ -0,0 +1,10 @@ +! PR fortran/44536 +! { dg-do compile } +! { dg-options "-fopenmp" } + subroutine foo (a, i, j) + integer, dimension(:) :: a + integer :: i, j +!$omp parallel default(none) shared(i, j) ! { dg-error "enclosing parallel" } + j=a(i) ! { dg-error "not specified in" } +!$omp end parallel + end subroutine diff --git a/gcc/testsuite/gfortran.dg/gomp/sharing-3.f90 b/gcc/testsuite/gfortran.dg/gomp/sharing-3.f90 index 5c1581454b2..05be38283a9 100644 --- a/gcc/testsuite/gfortran.dg/gomp/sharing-3.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/sharing-3.f90 @@ -29,7 +29,7 @@ subroutine foo (vara, varb, varc, vard, n) !$omp master vara(1) = 1 ! { dg-error "not specified" } varb(1) = 1 ! Assumed-size is predetermined - varc(1) = 1 ! { dg-error "not specified" "" { xfail *-*-* } } + varc(1) = 1 ! { dg-error "not specified" } vard(1) = 1 ! { dg-error "not specified" } vare(1) = 1 ! { dg-error "not specified" } !$omp end master diff --git a/gcc/testsuite/gfortran.dg/ibclr_1.f90 b/gcc/testsuite/gfortran.dg/ibclr_1.f90 new file mode 100644 index 00000000000..3932789ec4f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ibclr_1.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +program a + integer :: i = 42 + integer l + l = ibclr(i, -1) ! { dg-error "must be nonnegative" } + l = ibclr(i, 65) ! { dg-error "must be less than" } +end program a diff --git a/gcc/testsuite/gfortran.dg/ibits_1.f90 b/gcc/testsuite/gfortran.dg/ibits_1.f90 new file mode 100644 index 00000000000..2bcbe829b86 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ibits_1.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! +! PR fortran/44346 +! Original test sumbitted by Vittorio Zecca, zeccav at gmail dot com. +! Modified by Steven G. Kargl for dejagnu testsuite. +! +program a + integer :: j, i = 42 + j = ibits(i, -1, 1) ! { dg-error "must be nonnegative" } + j = ibits(i, 1, -1) ! { dg-error "must be nonnegative" } + j = ibits(i, 100, 100) ! { dg-error "must be less than" } +end program a + diff --git a/gcc/testsuite/gfortran.dg/ibset_1.f90 b/gcc/testsuite/gfortran.dg/ibset_1.f90 new file mode 100644 index 00000000000..2ff261dbd2b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ibset_1.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +program a + integer :: i = 42 + integer l + l = ibset(i, -1) ! { dg-error "must be nonnegative" } + l = ibset(i, 65) ! { dg-error "must be less than" } +end program a diff --git a/gcc/testsuite/gfortran.dg/import8.f90 b/gcc/testsuite/gfortran.dg/import8.f90 new file mode 100644 index 00000000000..0d88e625b81 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/import8.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! +! PR fortran/44614 +! +! + +implicit none + +type, abstract :: Connection +end type Connection + +abstract interface + subroutine generic_desc(self) + ! <<< missing IMPORT + class(Connection) :: self ! { dg-error "has not been declared within the interface" } + end subroutine generic_desc +end interface +end diff --git a/gcc/testsuite/gfortran.dg/interface_proc_end.f90 b/gcc/testsuite/gfortran.dg/interface_proc_end.f90 index ab95b794268..2fc9921df41 100644 --- a/gcc/testsuite/gfortran.dg/interface_proc_end.f90 +++ b/gcc/testsuite/gfortran.dg/interface_proc_end.f90 @@ -14,6 +14,5 @@ REAL :: TLS1,TLS2 END ! OK END INTERFACE - end ! { dg-error "END SUBROUTINE statement" } - end module ! { dg-error "END SUBROUTINE statement" } -! { dg-error "Unexpected end of file" "" { target "*-*-*" } 0 } + end subroutine + end module diff --git a/gcc/testsuite/gfortran.dg/ltrans-7.f90 b/gcc/testsuite/gfortran.dg/ltrans-7.f90 index 2829b2cda18..9c9bcf939eb 100644 --- a/gcc/testsuite/gfortran.dg/ltrans-7.f90 +++ b/gcc/testsuite/gfortran.dg/ltrans-7.f90 @@ -1,5 +1,6 @@ ! { dg-do compile } ! { dg-options "-O2 -ftree-loop-linear -fdump-tree-ltrans-all" } +! { dg-options "-O2 -ftree-loop-linear -fdump-tree-ltrans-all -march=i486" { target { i?86-*-* && ilp32 } } } Program FOO IMPLICIT INTEGER (I-N) diff --git a/gcc/testsuite/gfortran.dg/mvbits_9.f90 b/gcc/testsuite/gfortran.dg/mvbits_9.f90 new file mode 100644 index 00000000000..952286b09a6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/mvbits_9.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! +! PR fortran/44346 +! Original test sumbitted by Vittorio Zecca, zeccav at gmail dot com. +! Modified by Steven G. Kargl for dejagnu testsuite. +! +program a + integer :: n = 42 + ! 64 + 3 > bitsize(n) + call mvbits(n, 64, 3, n, 1) ! { dg-error "must be less than" } + ! 64 + 2 > bitsize(n) + call mvbits(n, 30, 2, n, 64) ! { dg-error "must be less than" } + ! LEN negative + call mvbits(n, 30, -2, n, 30) ! { dg-error "must be nonnegative" } + ! TOPOS negative + call mvbits(n, 30, 2, n, -3) ! { dg-error "must be nonnegative" } + ! FROMPOS negative + call mvbits(n, -1, 2, n, 3) ! { dg-error "must be nonnegative" } +end program a diff --git a/gcc/testsuite/gfortran.dg/nan_6.f90 b/gcc/testsuite/gfortran.dg/nan_6.f90 new file mode 100644 index 00000000000..8f0af294420 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/nan_6.f90 @@ -0,0 +1,99 @@ +! { dg-do run } +! { dg-add-options ieee } +! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } } +! +! List-directed part of PR fortran/43298 +! and follow up to PR fortran/34319. +! +! Check handling of "NAN(alphanum)" +! +character(len=200) :: str +real :: r +complex :: z + +! read_real: + +r = 1.0 +str = 'INfinity' ; read(str,*) r +if (r < 0 .or. r /= r*1.1) call abort() + +r = 1.0 +str = '-INF' ; read(str,*) r +if (r > 0 .or. r /= r*1.1) call abort() + +r = 1.0 +str = '+INF' ; read(str,*) r +if (r < 0 .or. r /= r*1.1) call abort() + +r = 1.0 +str = '-inFiniTY' ; read(str,*) r +if (r > 0 .or. r /= r*1.1) call abort() + +r = 1.0 +str = 'NAN' ; read(str,*) r +if (.not. isnan(r)) call abort() + +r = 1.0 +str = '-NAN' ; read(str,*) r +if (.not. isnan(r)) call abort() + +r = 1.0 +str = '+NAN' ; read(str,*) r +if (.not. isnan(r)) call abort() + +r = 1.0 +str = 'NAN(0x111)' ; read(str,*) r +if (.not. isnan(r)) call abort() + +r = 1.0 +str = '-NAN(123)' ; read(str,*) r +if (.not. isnan(r)) call abort() + +r = 1.0 +str = '+NAN(0xFFE)' ; read(str,*) r +if (.not. isnan(r)) call abort() + + +! parse_real + +z = cmplx(-2.0,-4.0) +str = '(0.0,INfinity)' ; read(str,*) z +if (aimag(z) < 0 .or. aimag(z) /= aimag(z)*1.1) call abort() + +z = cmplx(-2.0,-4.0) +str = '(-INF,0.0)' ; read(str,*) z +if (real(z) > 0 .or. real(z) /= real(z)*1.1) call abort() + +z = cmplx(-2.0,-4.0) +str = '(0.0,+INF)' ; read(str,*) z +if (aimag(z) < 0 .or. aimag(z) /= aimag(z)*1.1) call abort() + +z = cmplx(-2.0,-4.0) +str = '(-inFiniTY,0.0)' ; read(str,*) z +if (real(z) > 0 .or. real(z) /= real(z)*1.1) call abort() + +z = cmplx(-2.0,-4.0) +str = '(NAN,0.0)' ; read(str,*) z +if (.not. isnan(real(z))) call abort() + +z = cmplx(-2.0,-4.0) +str = '(0.0,-NAN)' ; read(str,*) z +if (.not. isnan(aimag(z))) call abort() + +z = cmplx(-2.0,-4.0) +str = '(+NAN,0.0)' ; read(str,*) z +if (.not. isnan(real(z))) call abort() + +z = cmplx(-2.0,-4.0) +str = '(NAN(0x111),0.0)' ; read(str,*) z +if (.not. isnan(real(z))) call abort() + +z = cmplx(-2.0,-4.0) +str = '(0.0,-NaN(123))' ; read(str,*) z +if (.not. isnan(aimag(z))) call abort() + +z = cmplx(-2.0,-4.0) +str = '(+nan(0xFFE),0.0)' ; read(str,*) z +if (.not. isnan(real(z))) call abort() + +end diff --git a/gcc/testsuite/gfortran.dg/pr43688.f90 b/gcc/testsuite/gfortran.dg/pr43688.f90 new file mode 100644 index 00000000000..face02212b8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr43688.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-O0 -fipa-reference" } + + subroutine sub + type :: a + integer :: i = 42 + end type a + type(a), target :: dt(2) + integer, pointer :: ip(:) + ip => dt%i + end subroutine diff --git a/gcc/testsuite/gfortran.dg/pr43866.f90 b/gcc/testsuite/gfortran.dg/pr43866.f90 new file mode 100644 index 00000000000..abfdaa1557f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr43866.f90 @@ -0,0 +1,44 @@ +! PR middle-end/43866 +! { dg-do run } +! { dg-options "-funswitch-loops -fbounds-check" } + +MODULE PR43866 + IMPLICIT NONE + TYPE TT + REAL(KIND=4), DIMENSION(:,:), POINTER :: A + REAL(KIND=8), DIMENSION(:,:), POINTER :: B + END TYPE +CONTAINS + SUBROUTINE FOO(M,X,Y,T) + TYPE(TT), POINTER :: M + INTEGER, INTENT(IN) :: Y, X + INTEGER :: C, D + LOGICAL :: T + REAL(KIND = 4), DIMENSION(:,:), POINTER :: P + REAL(KIND = 8), DIMENSION(:,:), POINTER :: Q + + Q => M%B + P => M%A + DO C=1,X + DO D=C+1,Y + IF (T) THEN + P(D,C)=P(C,D) + ELSE + Q(D,C)=Q(C,D) + ENDIF + ENDDO + ENDDO + END SUBROUTINE FOO +END MODULE PR43866 + + USE PR43866 + TYPE(TT), POINTER :: Q + INTEGER, PARAMETER :: N=17 + ALLOCATE (Q) + NULLIFY (Q%A) + ALLOCATE (Q%B(N,N)) + Q%B=0 + CALL FOO (Q,N,N,.FALSE.) +END + +! { dg-final { cleanup-modules "pr43866" } } diff --git a/gcc/testsuite/gfortran.dg/pr44592.f90 b/gcc/testsuite/gfortran.dg/pr44592.f90 new file mode 100644 index 00000000000..8b043ba33ed --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr44592.f90 @@ -0,0 +1,20 @@ +! { dg-do run } +! { dg-options "-O3" } +! From forall_12.f90 +! Fails with loop reversal at -O3 +! + character(len=1) :: b(4) = (/"1","2","3","4"/), c(4) + c = b + i = 1 + ! This statement must be here for the abort below + b(1:3)(i:i) = b(2:4)(i:i) + + b = c + b(4:2:-1)(i:i) = b(3:1:-1)(i:i) + + ! This fails. If the condition is printed, the result is F F F F + if (any (b .ne. (/"1","1","2","3"/))) i = 2 + print *, b + print *, b .ne. (/"1","1","2","3"/) + if (i == 2) call abort +end diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_27.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_27.f90 new file mode 100644 index 00000000000..83f09598110 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_27.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! +! PR fortran/44446 +! +! Contributed by Marco Restelli. +! +! Procedure pointer with PROTECTED was wrongly rejected. +! +module m + implicit none + abstract interface + pure function i_f(x) result(y) + real, intent(in) :: x + real :: y + end function i_f + end interface + procedure(i_f), pointer, protected :: p_f => null() +end module m + +! { dg-final { cleanup-modules "m" } } diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_28.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_28.f90 new file mode 100644 index 00000000000..8754d8e2982 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_28.f90 @@ -0,0 +1,39 @@ +! { dg-do compile } +! +! PR 44718: Procedure-pointer name is wrongly regarded as "external procedure" +! +! Contributed by John McFarland <john.mcfarland@swri.org> + +MODULE m + + IMPLICIT NONE + +CONTAINS + + FUNCTION func(x) RESULT(y) + INTEGER :: x,y + y = x *2 + END FUNCTION func + + SUBROUTINE sub(x) + INTEGER :: x + PRINT*, x + END SUBROUTINE sub + + + SUBROUTINE use_func() + PROCEDURE(func), POINTER :: f + INTEGER :: y + f => func + y = f(2) + END SUBROUTINE use_func + + SUBROUTINE use_sub() + PROCEDURE(sub), POINTER :: f + f => sub + CALL f(2) + END SUBROUTINE use_sub + +END MODULE m + +! { dg-final { cleanup-modules "m" } } diff --git a/gcc/testsuite/gfortran.dg/read_infnan_1.f90 b/gcc/testsuite/gfortran.dg/read_infnan_1.f90 new file mode 100644 index 00000000000..515a6900270 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/read_infnan_1.f90 @@ -0,0 +1,31 @@ +! { dg-do run } +! { dg-add-options ieee } +! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } } + +! PR43298 Fortran library does not read in NaN, NaN(), -Inf, or Inf + +! Formatted READ part of PR fortran/43298 + +! Test case prepared by Jerry DeLisle <jvdelisle@gcc.gnu.org> +program pr43298 + real(4) :: x4(7) + real(8) :: x8(7) + character(80) :: output + +open(10, status='scratch') +! 0123456789012345678901234567890123456789012345678901234567890123456789 +write(10,'(a)') "inf nan infinity NaN(dx) -INf NAN InFiNiTy" +rewind(10) +x4 = 0.0_4 +x8 = 0.0_8 +read(10,'(7f10.3)') x4 +rewind(10) +read(10,'(7f10.3)') x8 +write (output, '("x4 =",7G6.0)') x4 +if (output.ne."x4 = +Inf NaN +Inf NaN -Inf NaN +Inf") call abort +write (output, '("x8 =",7G6.0)') x8 +if (output.ne."x8 = +Inf NaN +Inf NaN -Inf NaN +Inf") call abort +!print '("x4 =",7G6.0)', x4 +!print '("x8 =",7G6.0)', x8 +end program pr43298 + diff --git a/gcc/testsuite/gfortran.dg/selected_char_kind_4.f90 b/gcc/testsuite/gfortran.dg/selected_char_kind_4.f90 new file mode 100644 index 00000000000..046ddf0e74c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/selected_char_kind_4.f90 @@ -0,0 +1,24 @@ +! { dg-do run } +! +! Check that runtime result values of SELECTED_CHAR_KIND agree with +! front-end simplification results. +! + implicit none + character(len=20) :: s + + s = "ascii" + if (selected_char_kind(s) /= selected_char_kind("ascii")) call abort + + s = "default" + if (selected_char_kind(s) /= selected_char_kind("default")) call abort + + s = "iso_10646" + if (selected_char_kind(s) /= selected_char_kind("iso_10646")) call abort + + s = "" + if (selected_char_kind(s) /= selected_char_kind("")) call abort + + s = "invalid" + if (selected_char_kind(s) /= selected_char_kind("invalid")) call abort + +end diff --git a/gcc/testsuite/gfortran.dg/selected_real_kind_1.f90 b/gcc/testsuite/gfortran.dg/selected_real_kind_1.f90 new file mode 100644 index 00000000000..0f40a595d2f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/selected_real_kind_1.f90 @@ -0,0 +1,10 @@ +! { dg-do "compile" } +! +! PR fortran/44347 - arguments of SELECTED_REAL_KIND shall be scalar +! Testcase contributed by Vittorio Zecca <zeccav AT gmail DOT com> +! + + dimension ip(1), ir(1) + i = selected_real_kind(ip, i) ! { dg-error "must be a scalar" } + j = selected_real_kind(i, ir) ! { dg-error "must be a scalar" } +end diff --git a/gcc/testsuite/gfortran.dg/selected_real_kind_2.f90 b/gcc/testsuite/gfortran.dg/selected_real_kind_2.f90 new file mode 100644 index 00000000000..cf73520f930 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/selected_real_kind_2.f90 @@ -0,0 +1,32 @@ +! { dg-do run } +! { dg-options "-std=f2008 -fall-intrinsics" } +! + +integer :: p, r, rdx + +! Compile-time version + +if (selected_real_kind(radix=2) /= 4) call should_not_fail() +if (selected_real_kind(radix=4) /= -5) call should_not_fail() +if (selected_real_kind(precision(0.0),range(0.0),radix(0.0)) /= kind(0.0)) & + call should_not_fail() +if (selected_real_kind(precision(0.0d0),range(0.0d0),radix(0.0d0)) /= kind(0.0d0)) & + call should_not_fail() + +! Run-time version + +rdx = 2 +if (selected_real_kind(radix=rdx) /= 4) call abort() +rdx = 4 +if (selected_real_kind(radix=rdx) /= -5) call abort() + +rdx = radix(0.0) +p = precision(0.0) +r = range(0.0) +if (selected_real_kind(p,r,rdx) /= kind(0.0)) call abort() + +rdx = radix(0.0d0) +p = precision(0.0d0) +r = range(0.0d0) +if (selected_real_kind(p,r,rdx) /= kind(0.0d0)) call abort() +end diff --git a/gcc/testsuite/gfortran.dg/selected_real_kind_3.f90 b/gcc/testsuite/gfortran.dg/selected_real_kind_3.f90 new file mode 100644 index 00000000000..d24d877acfe --- /dev/null +++ b/gcc/testsuite/gfortran.dg/selected_real_kind_3.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +print *, selected_real_kind(p=precision(0.0),radix=2) ! { dg-error "Fortran 2008" } +print *, selected_real_kind() ! { dg-error "neither 'P' nor 'R' argument" } +end diff --git a/gcc/testsuite/gfortran.dg/semicolon_fixed.f b/gcc/testsuite/gfortran.dg/semicolon_fixed.f index 2c667ae0cb9..7bd0ada825c 100644 --- a/gcc/testsuite/gfortran.dg/semicolon_fixed.f +++ b/gcc/testsuite/gfortran.dg/semicolon_fixed.f @@ -1,9 +1,11 @@ ! { dg-do compile } -! PR 19259 Semicolon cannot start a line +! { dg-options "-std=f2003" } +! +! PR 19259 Semicolon cannot start a line (in F2003) x=1; y=1; x=2;; x=3; - ; ! { dg-error "Semicolon at" } - ;; ! { dg-error "Semicolon at" } + ; ! { dg-error "Fortran 2008: Semicolon at" } + ;; ! { dg-error "Fortran 2008: Semicolon at" } 900 ; ! { dg-error "Semicolon at" } end diff --git a/gcc/testsuite/gfortran.dg/semicolon_fixed_2.f b/gcc/testsuite/gfortran.dg/semicolon_fixed_2.f new file mode 100644 index 00000000000..8ee444c3ff5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/semicolon_fixed_2.f @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } + +! PR 19259 Semicolon cannot start a line +! but it F2008 it can! + x=1; y=1; + x=2;; + x=3; + ; ! OK + ;; ! OK + 900 ; ! { dg-error "Semicolon at" } + end diff --git a/gcc/testsuite/gfortran.dg/semicolon_free.f90 b/gcc/testsuite/gfortran.dg/semicolon_free.f90 index 28e8da2b285..4d05d83f86b 100644 --- a/gcc/testsuite/gfortran.dg/semicolon_free.f90 +++ b/gcc/testsuite/gfortran.dg/semicolon_free.f90 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-std=f2003" } ! PR 19259 Semicolon cannot start a line x=1; y=1; x=2;; diff --git a/gcc/testsuite/gfortran.dg/semicolon_free_2.f90 b/gcc/testsuite/gfortran.dg/semicolon_free_2.f90 new file mode 100644 index 00000000000..2fae26e1607 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/semicolon_free_2.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +! PR 19259 Semicolon cannot start a line +x=1; y=1; +x=2;; +x=3; + ; ! OK +;; ! OK +111 ; ! { dg-error "Semicolon at" } +end diff --git a/gcc/testsuite/gfortran.dg/type_decl_1.f90 b/gcc/testsuite/gfortran.dg/type_decl_1.f90 new file mode 100644 index 00000000000..93928652a05 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/type_decl_1.f90 @@ -0,0 +1,30 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +! +! Fortran 2008: TYPE ( intrinsic-type-spec ) +! +implicit none +type(integer) :: a +type(real) :: b +type(logical ) :: c +type(character) :: d +type(double precision) :: e + +type(integer(8)) :: f +type(real(kind=4)) :: g +type(logical ( kind = 1 ) ) :: h +type(character (len=10,kind=1) ) :: i + +type(double complex) :: j ! { dg-error "Extension: DOUBLE COMPLEX" } +end + +module m + integer, parameter :: k4 = 4 +end module m + +type(integer (kind=k4)) function f() + use m + f = 42 +end + +! { dg-final { cleanup-modules "m" } } diff --git a/gcc/testsuite/gfortran.dg/type_decl_2.f90 b/gcc/testsuite/gfortran.dg/type_decl_2.f90 new file mode 100644 index 00000000000..6525880e06e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/type_decl_2.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +! Fortran 2008: TYPE ( intrinsic-type-spec ) +! +implicit none +type(integer) :: a ! { dg-error "Fortran 2008" } +type(real) :: b ! { dg-error "Fortran 2008" } +type(logical) :: c ! { dg-error "Fortran 2008" } +type(character) :: d ! { dg-error "Fortran 2008" } +type(double precision) :: e ! { dg-error "Fortran 2008" } +end diff --git a/gcc/testsuite/gfortran.dg/typebound_call_14.f03 b/gcc/testsuite/gfortran.dg/typebound_call_14.f03 new file mode 100644 index 00000000000..e8cbf846e5d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_call_14.f03 @@ -0,0 +1,29 @@ +! { dg-do compile } +! +! PR 44211: [OOP] ICE with TBP of pointer component of derived type array +! +! Original test case by Hans-Werner Boschmann <boschmann@tp1.physik.uni-siegen.de> +! Modified by Janus Weil <janus@gcc.gnu.org> + +module ice_module + type::ice_type + class(ice_type),pointer::next + contains + procedure::ice_sub + procedure::ice_fun + end type ice_type +contains + subroutine ice_sub(this) + class(ice_type)::this + end subroutine + integer function ice_fun(this) + class(ice_type)::this + end function + subroutine ice() + type(ice_type),dimension(2)::ice_array + call ice_array(1)%next%ice_sub() + print *,ice_array(2)%next%ice_fun() + end subroutine +end module ice_module + +! { dg-final { cleanup-modules "ice_module" } } diff --git a/gcc/testsuite/gfortran.dg/typebound_call_15.f03 b/gcc/testsuite/gfortran.dg/typebound_call_15.f03 new file mode 100644 index 00000000000..ac6a668cc46 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_call_15.f03 @@ -0,0 +1,25 @@ +! { dg-do compile } +! +! PR 44558: [OOP] ICE on invalid code: called TBP subroutine as TBP function +! +! Contributed by Hans-Werner Boschmann <boschmann@tp1.physik.uni-siegen.de> + +module ice5 + type::a_type + contains + procedure::a_subroutine_1 + procedure::a_subroutine_2 + end type a_type +contains + real function a_subroutine_1(this) + class(a_type)::this + real::res + res=this%a_subroutine_2() ! { dg-error "should be a FUNCTION" } + end function + subroutine a_subroutine_2(this) + class(a_type)::this + call this%a_subroutine_1() ! { dg-error "should be a SUBROUTINE" } + end subroutine +end module ice5 + +! { dg-final { cleanup-modules "ice5" } } diff --git a/gcc/testsuite/gfortran.dg/typebound_proc_14.f03 b/gcc/testsuite/gfortran.dg/typebound_proc_14.f03 new file mode 100644 index 00000000000..766a0ef66c1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_proc_14.f03 @@ -0,0 +1,33 @@ +! { dg-do compile } +! +! PR 40117: [OOP][F2008] Type-bound procedure: allow list after PROCEDURE +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +module m + +implicit none + +type :: t +contains + procedure :: foo, bar, baz +end type + +contains + + subroutine foo (this) + class(t) :: this + end subroutine + + real function bar (this) + class(t) :: this + end function + + subroutine baz (this, par) + class(t) :: this + integer :: par + end subroutine + +end + +! { dg-final { cleanup-modules "m" } } diff --git a/gcc/testsuite/gfortran.dg/typebound_proc_15.f03 b/gcc/testsuite/gfortran.dg/typebound_proc_15.f03 new file mode 100644 index 00000000000..37907b3f4df --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_proc_15.f03 @@ -0,0 +1,34 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +! PR 40117: [OOP][F2008] Type-bound procedure: allow list after PROCEDURE +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +module m + +implicit none + +type :: t +contains + procedure :: foo + procedure :: bar, baz ! { dg-error "PROCEDURE list" } +end type + +contains + + subroutine foo (this) + class(t) :: this + end subroutine + + subroutine bar (this) + class(t) :: this + end subroutine + + subroutine baz (this) + class(t) :: this + end subroutine + +end + +! { dg-final { cleanup-modules "m" } } diff --git a/gcc/testsuite/gfortran.dg/typebound_proc_16.f03 b/gcc/testsuite/gfortran.dg/typebound_proc_16.f03 new file mode 100644 index 00000000000..828f5102204 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_proc_16.f03 @@ -0,0 +1,58 @@ +! { dg-do compile } +! +! PR 44549: [OOP][F2008] Type-bound procedure: bogus error from list after PROCEDURE +! +! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr> + +MODULE rational_numbers + IMPLICIT NONE + PRIVATE + TYPE,PUBLIC :: rational + PRIVATE + INTEGER n,d + + CONTAINS + ! ordinary type-bound procedure + PROCEDURE :: real => rat_to_real + ! specific type-bound procedures for generic support + PROCEDURE,PRIVATE :: rat_asgn_i, rat_plus_rat, rat_plus_i + PROCEDURE,PRIVATE,PASS(b) :: i_plus_rat + ! generic type-bound procedures + GENERIC :: ASSIGNMENT(=) => rat_asgn_i + GENERIC :: OPERATOR(+) => rat_plus_rat, rat_plus_i, i_plus_rat + END TYPE + CONTAINS + ELEMENTAL REAL FUNCTION rat_to_real(this) RESULT(r) + CLASS(rational),INTENT(IN) :: this + r = REAL(this%n)/this%d + END FUNCTION + + ELEMENTAL SUBROUTINE rat_asgn_i(a,b) + CLASS(rational),INTENT(OUT) :: a + INTEGER,INTENT(IN) :: b + a%n = b + a%d = 1 + END SUBROUTINE + + ELEMENTAL TYPE(rational) FUNCTION rat_plus_i(a,b) RESULT(r) + CLASS(rational),INTENT(IN) :: a + INTEGER,INTENT(IN) :: b + r%n = a%n + b*a%d + r%d = a%d + END FUNCTION + + ELEMENTAL TYPE(rational) FUNCTION i_plus_rat(a,b) RESULT(r) + INTEGER,INTENT(IN) :: a + CLASS(rational),INTENT(IN) :: b + r%n = b%n + a*b%d + r%d = b%d + END FUNCTION + + ELEMENTAL TYPE(rational) FUNCTION rat_plus_rat(a,b) RESULT(r) + CLASS(rational),INTENT(IN) :: a,b + r%n = a%n*b%d + b%n*a%d + r%d = a%d*b%d + END FUNCTION +END + +! { dg-final { cleanup-modules "rational_numbers" } } diff --git a/gcc/testsuite/gfortran.dg/typebound_proc_4.f03 b/gcc/testsuite/gfortran.dg/typebound_proc_4.f03 index 92adc1a852a..60aa728a40f 100644 --- a/gcc/testsuite/gfortran.dg/typebound_proc_4.f03 +++ b/gcc/testsuite/gfortran.dg/typebound_proc_4.f03 @@ -17,12 +17,12 @@ MODULE testmod PROCEDURE ? ! { dg-error "Expected binding name" } PROCEDURE :: p2 => ! { dg-error "Expected binding target" } PROCEDURE :: p3 =>, ! { dg-error "Expected binding target" } - PROCEDURE p4, ! { dg-error "Junk after" } - PROCEDURE :: p5 => proc2, ! { dg-error "Junk after" } + PROCEDURE p4, ! { dg-error "Expected binding name" } + PROCEDURE :: p5 => proc2, ! { dg-error "Expected binding name" } PROCEDURE :: p0 => proc3 ! { dg-error "already a procedure" } PROCEDURE, PASS p6 ! { dg-error "::" } PROCEDURE, PASS NON_OVERRIDABLE ! { dg-error "Expected" } - PROCEDURE PASS :: ! { dg-error "Junk after" } + PROCEDURE PASS :: ! { dg-error "Syntax error" } PROCEDURE, PASS (x ! { dg-error "Expected" } PROCEDURE, PASS () ! { dg-error "Expected" } PROCEDURE, NOPASS, PASS ! { dg-error "illegal PASS" } diff --git a/gcc/testsuite/gfortran.dg/unpack_bounds_1.f90 b/gcc/testsuite/gfortran.dg/unpack_bounds_1.f90 index 360790b5705..360790b5705 100755..100644 --- a/gcc/testsuite/gfortran.dg/unpack_bounds_1.f90 +++ b/gcc/testsuite/gfortran.dg/unpack_bounds_1.f90 diff --git a/gcc/testsuite/gfortran.dg/unpack_bounds_2.f90 b/gcc/testsuite/gfortran.dg/unpack_bounds_2.f90 index fd049f5abbb..fd049f5abbb 100755..100644 --- a/gcc/testsuite/gfortran.dg/unpack_bounds_2.f90 +++ b/gcc/testsuite/gfortran.dg/unpack_bounds_2.f90 diff --git a/gcc/testsuite/gfortran.dg/unpack_bounds_3.f90 b/gcc/testsuite/gfortran.dg/unpack_bounds_3.f90 index c6734b14c1f..c6734b14c1f 100755..100644 --- a/gcc/testsuite/gfortran.dg/unpack_bounds_3.f90 +++ b/gcc/testsuite/gfortran.dg/unpack_bounds_3.f90 diff --git a/gcc/testsuite/gfortran.dg/warn_conversion.f90 b/gcc/testsuite/gfortran.dg/warn_conversion.f90 index f658b655cae..c8f0e23e2ff 100644 --- a/gcc/testsuite/gfortran.dg/warn_conversion.f90 +++ b/gcc/testsuite/gfortran.dg/warn_conversion.f90 @@ -18,7 +18,6 @@ SUBROUTINE pr27866c4 integer(kind=4) :: i4 i4 = 2.3 ! { dg-warning "conversion" } i1 = 500 ! { dg-error "overflow" } - ! { dg-warning "conversion" "" { target *-*-* } 20 } a = 2**26-1 ! assignment INTEGER(4) to REAL(4) - no warning b = 1d999 ! { dg-error "overflow" } diff --git a/gcc/testsuite/gfortran.dg/warn_conversion_2.f90 b/gcc/testsuite/gfortran.dg/warn_conversion_2.f90 index cb3b760a5e2..c0222983a0f 100644 --- a/gcc/testsuite/gfortran.dg/warn_conversion_2.f90 +++ b/gcc/testsuite/gfortran.dg/warn_conversion_2.f90 @@ -2,5 +2,10 @@ ! { dg-options "-Wconversion-extra" } real(8) :: sqrt2 - sqrt2 = sqrt(2.0) ! { dg-warning "conversion" } + real x + + x = 2.0 + sqrt2 = sqrt(x) ! { dg-warning "Conversion" } + + sqrt2 = sqrt(2.0) ! no warning; simplified to a constant and range checked end diff --git a/gcc/testsuite/gfortran.dg/whole_file_18.f90 b/gcc/testsuite/gfortran.dg/whole_file_18.f90 index dbff1859216..fac15d6ca4f 100644 --- a/gcc/testsuite/gfortran.dg/whole_file_18.f90 +++ b/gcc/testsuite/gfortran.dg/whole_file_18.f90 @@ -5,7 +5,7 @@ ! PROGRAM MAIN REAL A - CALL SUB(A) ! { dg-error "must have an explicit interface" } + CALL SUB(A) ! { dg-error "requires an explicit interface" } END PROGRAM SUBROUTINE SUB(A,I) diff --git a/gcc/testsuite/gfortran.dg/whole_file_20.f03 b/gcc/testsuite/gfortran.dg/whole_file_20.f03 new file mode 100644 index 00000000000..231a5aaf283 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/whole_file_20.f03 @@ -0,0 +1,33 @@ +! { dg-do "compile" } +! { dg-options "-fwhole-file -fcoarray=single" } +! +! Procedures with dummy arguments that are coarrays or polymorphic +! must have an explicit interface in the calling routine. +! + +MODULE classtype + type :: t + integer :: comp + end type +END MODULE + +PROGRAM main + USE classtype + CLASS(t), POINTER :: tt + + INTEGER :: coarr[*] + + CALL coarray(coarr) ! { dg-error " must have an explicit interface" } + CALL polymorph(tt) ! { dg-error " must have an explicit interface" } +END PROGRAM + +SUBROUTINE coarray(a) + INTEGER :: a[*] +END SUBROUTINE + +SUBROUTINE polymorph(b) + USE classtype + CLASS(t) :: b +END SUBROUTINE + +! { dg-final { cleanup-modules "classtype" } } |