| 1 |
! { dg-do compile } |
| 2 |
! |
| 3 |
! Check the fix for an ICE in gfc_conv_expr_present, which resulted from |
| 4 |
! the rhs temporary picking up the optional attribute from the lhs in a |
| 5 |
! defined assignment. |
| 6 |
! |
| 7 |
! Contributed by Jakub Jelenik <[email protected]> |
| 8 |
! |
| 9 |
module foo |
| 10 |
type t1 |
| 11 |
contains |
| 12 |
procedure bar |
| 13 |
generic :: assignment(=) => bar |
| 14 |
end type |
| 15 |
type t2 |
| 16 |
type(t1) m |
| 17 |
end type |
| 18 |
contains |
| 19 |
subroutine bar (x, y) |
| 20 |
intent(in) y |
| 21 |
class(t1), intent(out) :: x |
| 22 |
end subroutine |
| 23 |
end module |
| 24 |
subroutine baz (x, y) |
| 25 |
use foo |
| 26 |
integer y |
| 27 |
type(t2), pointer, optional :: x |
| 28 |
interface |
| 29 |
function qux (x) |
| 30 |
use foo |
| 31 |
integer x |
| 32 |
type(t2) qux |
| 33 |
end function |
| 34 |
end interface |
| 35 |
if (present (x)) then |
| 36 |
x = qux (y) ! ICE was here |
| 37 |
end if |
| 38 |
end subroutine |