1 // PERMUTE_ARGS:
2 // REQUIRED_ARGS: -w -o-
3 
4 /*
5 TEST_OUTPUT:
6 ---
7 fail_compilation/b3841.d-mixin-31(31): Warning: char += float is performing truncating conversion
8 fail_compilation/b3841.d-mixin-31(31): Warning: int += float is performing truncating conversion
9 fail_compilation/b3841.d-mixin-31(31): Warning: long += double is performing truncating conversion
10 fail_compilation/b3841.d-mixin-31(31): Warning: char -= float is performing truncating conversion
11 fail_compilation/b3841.d-mixin-31(31): Warning: int -= float is performing truncating conversion
12 fail_compilation/b3841.d-mixin-31(31): Warning: long -= double is performing truncating conversion
13 fail_compilation/b3841.d-mixin-31(31): Warning: char *= float is performing truncating conversion
14 fail_compilation/b3841.d-mixin-31(31): Warning: int *= float is performing truncating conversion
15 fail_compilation/b3841.d-mixin-31(31): Warning: long *= double is performing truncating conversion
16 fail_compilation/b3841.d-mixin-31(31): Warning: char /= float is performing truncating conversion
17 fail_compilation/b3841.d-mixin-31(31): Warning: int /= float is performing truncating conversion
18 fail_compilation/b3841.d-mixin-31(31): Warning: long /= double is performing truncating conversion
19 fail_compilation/b3841.d-mixin-31(31): Warning: char %= float is performing truncating conversion
20 fail_compilation/b3841.d-mixin-31(31): Warning: int %= float is performing truncating conversion
21 fail_compilation/b3841.d-mixin-31(31): Warning: long %= double is performing truncating conversion
22 ---
23 */
24 
25 
f(string op,LHS,RHS)26 void f(string op, LHS, RHS)()
27 {
28     // pragma(msg, LHS, " += ", RHS);
29     LHS a;
30     RHS b;
31     mixin("a "~op~" b;");
32 }
33 
Ops(T...)34 template Ops(T...)
35 {
36     alias Ops = T;
37 }
38 
main()39 void main()
40 {
41     foreach (string op; Ops!("+=", "-=", "*=", "/=", "%="))
42     {
43         // OK
44         f!(op, int, int)();
45         f!(op, long, int)();
46         f!(op, long, short)();
47         f!(op, float, long)();
48         f!(op, cfloat, long)();
49         f!(op, double, float)();
50 
51         // Should that really be OK ?
52         f!(op, short, int)();
53         f!(op, float, double)();
54 
55         // Not OK, truncating conversion.
56         f!(op, char, float)();
57         f!(op, int, float)();
58         f!(op, long, double)();
59     }
60 
61     foreach (string op; Ops!("+=", "-="))
62     {
63         // OK
64         f!(op, idouble, ifloat)();
65 
66         // Should that really be OK ?
67         f!(op, ifloat, idouble)();
68     }
69 
70     // OK
71     f!("^^=", int, int)();
72     f!("^^=", long, int)();
73     f!("^^=", long, short)();
74     f!("^^=", float, long)();
75     f!("^^=", double, float)();
76     // Should that really be OK ?
77     f!("^^=", float, double)();
78 }