2 ! PR51634 - Handle allocatable components correctly in expressions
3 ! involving typebound operators. See comment 2 of PR.
5 ! Reported by Tobias Burnus <burnus@gcc.gnu.org>
7 module soop_stars_class
10 real, dimension(:), allocatable :: position,velocity
14 generic :: operator(+) => total
15 generic :: operator(*) => product
18 type(soop_stars) function product(lhs,rhs)
19 class(soop_stars) ,intent(in) :: lhs
20 real ,intent(in) :: rhs
21 product%position = lhs%position*rhs
22 product%velocity = lhs%velocity*rhs
25 type(soop_stars) function total(lhs,rhs)
26 class(soop_stars) ,intent(in) :: lhs,rhs
27 total%position = lhs%position + rhs%position
28 total%velocity = lhs%velocity + rhs%velocity
33 use soop_stars_class ,only : soop_stars
35 type(soop_stars) :: fireworks
37 fireworks%position = [1,2,3]
38 fireworks%velocity = [4,5,6]
40 fireworks = fireworks + fireworks*dt
41 if (any (fireworks%position .ne. [6, 12, 18])) STOP 1
42 if (any (fireworks%velocity .ne. [24, 30, 36])) STOP 2