summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/pr104429.f90
blob: 39761fd59fa6bc2a5528eb1fa6fbbc8cf380c159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
! { dg-do run }
!
! Contributed by Gerhard Steinmetz  <gscfq@t-online.de>
!
module m
   type t
      real :: r
   contains
      procedure :: op
      procedure :: assign
      generic :: operator(*) => op
      generic :: assignment(=) => assign
   end type
contains
   function op (x, y)
      class(t), allocatable :: op
      class(t), intent(in) :: x
      real, intent(in) :: y
      allocate (op, source = t (x%r * y))
   end
   subroutine assign (z, x)
      type(t), intent(in) :: x
      class(t), intent(out) :: z
      z%r = x%r
   end
end
program p
   use m
   class(t), allocatable :: x
   real :: y = 2
   allocate (x, source = t (2.0))
   x = x * y
   if (int (x%r) .ne. 4) stop 1
   if (allocated (x)) deallocate (x)
end