3 ! Type-bound procedures
4 ! Check for errors with operator calls.
12 PROCEDURE, PASS :: add_int
13 PROCEDURE, PASS :: assign_int
14 GENERIC, PRIVATE :: OPERATOR(.PLUS.) => add_int
15 GENERIC, PRIVATE :: OPERATOR(+) => add_int
16 GENERIC, PRIVATE :: ASSIGNMENT(=) => assign_int
22 PROCEDURE, PASS :: add_real
23 PROCEDURE, PASS :: assign_real
24 GENERIC :: OPERATOR(.PLUS.) => add_real
25 GENERIC :: OPERATOR(+) => add_real
26 GENERIC :: ASSIGNMENT(=) => assign_real
31 PURE TYPE(myint) FUNCTION add_int (a, b)
32 CLASS(myint), INTENT(IN) :: a
33 INTEGER, INTENT(IN) :: b
34 add_int = myint (a%value + b)
37 PURE SUBROUTINE assign_int (dest, from)
38 CLASS(myint), INTENT(OUT) :: dest
39 INTEGER, INTENT(IN) :: from
41 END SUBROUTINE assign_int
43 TYPE(myreal) FUNCTION add_real (a, b)
44 CLASS(myreal), INTENT(IN) :: a
46 add_real = myreal (a%value + b)
49 SUBROUTINE assign_real (dest, from)
50 CLASS(myreal), INTENT(OUT) :: dest
51 REAL, INTENT(IN) :: from
53 END SUBROUTINE assign_real
55 SUBROUTINE in_module ()
57 x = 0 ! { dg-bogus "Can't convert" }
58 x = x + 42 ! { dg-bogus "Operands of" }
59 x = x .PLUS. 5 ! { dg-bogus "Unknown operator" }
60 END SUBROUTINE in_module
62 PURE SUBROUTINE iampure ()
65 x = 0 ! { dg-bogus "is not PURE" }
66 x = x + 42 ! { dg-bogus "to a non-PURE procedure" }
67 x = x .PLUS. 5 ! { dg-bogus "to a non-PURE procedure" }
68 END SUBROUTINE iampure
72 PURE SUBROUTINE iampure2 ()
77 x = 0.0 ! { dg-error "is not PURE" }
78 x = x + 42.0 ! { dg-error "to a non-PURE procedure" }
79 x = x .PLUS. 5.0 ! { dg-error "to a non-PURE procedure" }
80 END SUBROUTINE iampure2
87 x = 0 ! { dg-error "Can't convert" }
88 x = x + 42 ! { dg-error "Operands of" }
89 x = x .PLUS. 5 ! { dg-error "Unknown operator" }