Increase timeout factor for hppa*-*-* in gcc.dg/long_branch.c
[official-gcc.git] / gcc / testsuite / gfortran.dg / overload_3.f90
bloba2fb47effd7a2edb560f0752af979484a7b83aaa
1 ! { dg-do run }
2 ! { dg-options "-fno-tree-vrp" }
3 ! PR fortran/89282
4 ! Contributed by Federico Perini.
6 module myclass
7 use iso_fortran_env, only: real64
8 implicit none
10 ! My generic type
11 type :: t
13 integer :: n=0
14 real(real64), allocatable :: x(:)
16 contains
18 procedure :: init => t_init
19 procedure :: destroy => t_destroy
20 procedure :: print => t_print
22 procedure, private, pass(this) :: x_minus_t
23 generic :: operator(-) => x_minus_t
26 end type t
28 contains
30 elemental subroutine t_destroy(this)
31 class(t), intent(inout) :: this
32 this%n=0
33 if (allocated(this%x)) deallocate(this%x)
34 end subroutine t_destroy
36 subroutine t_init(this,n)
37 class(t), intent(out) :: this
38 integer, intent(in) :: n
39 call this%destroy()
40 this%n=n
41 allocate(this%x(n))
42 end subroutine t_init
44 type(t) function x_minus_t(x,this) result(xmt)
45 real(real64), intent(in) :: x
46 class(t), intent(in) :: this
47 call xmt%init(this%n)
48 xmt%x(:) = x-this%x(:)
49 end function x_minus_t
51 subroutine t_print(this,msg)
52 class(t), intent(in) :: this
53 character(*), intent(in) :: msg
55 integer :: i
57 print "('type(t) object <',a,'>, size=',i0)", msg,this%n
58 do i=1,this%n
59 print "(' x(',i0,') =',1pe12.5)",i,this%x(i)
60 end do
62 end subroutine t_print
64 end module myclass
67 program test_overloaded
68 use myclass
69 implicit none
71 type(t) :: t1,r1
73 ! Error with result (5)
74 call t1%init(5); t1%x(:) = 1.0_real64; r1 = 3.0_real64 - t1
75 if (any(r1%x /= 2.0)) stop 1
76 ! call r1%print('r1')
78 ! No errors
79 call t1%init(6); t1%x(:) = 1.0_real64; r1 = 3.0_real64 - t1
80 if (any(r1%x /= 2.0)) stop 2
81 ! call r1%print('r1')
82 return
84 end program test_overloaded