| 1 | ! audit31 harvest: defined assignment(=) that converts an integer RHS |
| 2 | ! into a derived-type LHS, routed through a module's INTERFACE |
| 3 | ! ASSIGNMENT(=) block. Sprint 31 #466 fixed the segfault; this is |
| 4 | ! the canonical runtime check that the RHS is actually passed by |
| 5 | ! reference, the conversion procedure runs, and both LHS components |
| 6 | ! get populated. |
| 7 | ! CHECK: 10 20 |
| 8 | module audit31_assn_mod |
| 9 | implicit none |
| 10 | type :: pair |
| 11 | integer :: a = 0, b = 0 |
| 12 | end type |
| 13 | interface assignment(=) |
| 14 | module procedure assign_pair_from_int |
| 15 | end interface |
| 16 | contains |
| 17 | subroutine assign_pair_from_int(lhs, rhs) |
| 18 | type(pair), intent(out) :: lhs |
| 19 | integer, intent(in) :: rhs |
| 20 | lhs%a = rhs |
| 21 | lhs%b = rhs * 2 |
| 22 | end subroutine |
| 23 | end module |
| 24 | |
| 25 | program audit31_assn_cross_module |
| 26 | use audit31_assn_mod |
| 27 | implicit none |
| 28 | type(pair) :: q |
| 29 | q = 10 |
| 30 | print *, q%a, q%b |
| 31 | end program |
| 32 |