| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Test the fix for PR99124 which used to ICE as shown. |
| 4 |
! |
| 5 |
! Contributed by Gerhard Steinmetz <[email protected]> |
| 6 |
! |
| 7 |
module m |
| 8 |
type t |
| 9 |
integer :: i |
| 10 |
contains |
| 11 |
procedure :: f |
| 12 |
generic :: operator(+) => f |
| 13 |
end type |
| 14 |
contains |
| 15 |
elemental function f(a, b) result(c) |
| 16 |
class(t), intent(in) :: a, b |
| 17 |
type(t) :: c |
| 18 |
c = t(a%i + b%i) |
| 19 |
end |
| 20 |
end |
| 21 |
program p |
| 22 |
use m |
| 23 |
class(t), allocatable :: x(:), y(:), z |
| 24 |
allocate (x, source = [t(1), t(2)]) |
| 25 |
allocate (y, source = [t(1), t(2)]) |
| 26 |
x = x(2) + y ! ICE |
| 27 |
if (any (x%i .ne. [3, 4])) stop 1 |
| 28 |
z = x(1) |
| 29 |
x = z + y ! ICE |
| 30 |
if (any (x%i .ne. [4, 5])) stop 2 |
| 31 |
end |