| 1 | ! audit31 harvest: defined operator(+) on a derived type exported via |
| 2 | ! a module. Sprint 31 #465 / #477 fixed the single-TU resolution; |
| 3 | ! this pins the canonical form that links the module defining the |
| 4 | ! operator against the program that USEs it. Exercises generic |
| 5 | ! dispatch on '+' AND derived-type function result lowering AND |
| 6 | ! struct-by-value argument passing all in one small program. |
| 7 | ! CHECK: 4.0000000E0 6.0000000E0 |
| 8 | module audit31_op_single_mod |
| 9 | implicit none |
| 10 | type :: v2 |
| 11 | real :: x = 0.0, y = 0.0 |
| 12 | end type |
| 13 | interface operator(+) |
| 14 | module procedure add_v2 |
| 15 | end interface |
| 16 | contains |
| 17 | function add_v2(a, b) result(r) |
| 18 | type(v2), intent(in) :: a, b |
| 19 | type(v2) :: r |
| 20 | r%x = a%x + b%x |
| 21 | r%y = a%y + b%y |
| 22 | end function |
| 23 | end module |
| 24 | |
| 25 | program audit31_op_single |
| 26 | use audit31_op_single_mod |
| 27 | implicit none |
| 28 | type(v2) :: a, b, c |
| 29 | a%x = 1.0; a%y = 2.0 |
| 30 | b%x = 3.0; b%y = 4.0 |
| 31 | c = a + b |
| 32 | print *, c%x, c%y |
| 33 | end program |
| 34 |