2 ! PR48705 - ALLOCATE with class function expression for SOURCE failed.
3 ! This is the original test in the PR.
5 ! Reported by Tobias Burnus <burnus@gcc.gnu.org>
7 module generic_deferred
9 type, abstract :: addable
12 procedure(add), deferred :: a
13 generic, public :: operator(+) => a
16 function add(x, y) result(res)
18 class(addable), intent(in) :: x, y
19 class(addable), allocatable :: res
22 type, extends(addable) :: vec
25 procedure :: a => a_vec
28 function a_vec(x, y) result(res)
29 class(vec), intent(in) :: x
30 class(addable), intent(in) :: y
31 class(addable), allocatable :: res
43 end module generic_deferred
48 class(addable), allocatable :: z
49 ! x = vec( (/1,2/) ); y = vec( (/2,-2/) )
50 x%i = (/1,2/); y%i = (/2,-2/)
51 allocate(z, source= x + y)
54 if (z%i(1) /= 3 .or. z%i(2) /= 0) then