Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/b3841.d

raw
1 // REQUIRED_ARGS: -w -o-
2
3 /*
4 TEST_OUTPUT:
5 ---
6 fail_compilation/b3841.d-mixin-32(32): Warning: `char += float` is performing truncating conversion
7 fail_compilation/b3841.d-mixin-32(32): Warning: `int += float` is performing truncating conversion
8 fail_compilation/b3841.d-mixin-32(32): Warning: `long += double` is performing truncating conversion
9 fail_compilation/b3841.d-mixin-32(32): Warning: `char -= float` is performing truncating conversion
10 fail_compilation/b3841.d-mixin-32(32): Warning: `int -= float` is performing truncating conversion
11 fail_compilation/b3841.d-mixin-32(32): Warning: `long -= double` is performing truncating conversion
12 fail_compilation/b3841.d-mixin-32(32): Warning: `char *= float` is performing truncating conversion
13 fail_compilation/b3841.d-mixin-32(32): Warning: `int *= float` is performing truncating conversion
14 fail_compilation/b3841.d-mixin-32(32): Warning: `long *= double` is performing truncating conversion
15 fail_compilation/b3841.d-mixin-32(32): Warning: `char /= float` is performing truncating conversion
16 fail_compilation/b3841.d-mixin-32(32): Warning: `int /= float` is performing truncating conversion
17 fail_compilation/b3841.d-mixin-32(32): Warning: `long /= double` is performing truncating conversion
18 fail_compilation/b3841.d-mixin-32(32): Warning: `char %= float` is performing truncating conversion
19 fail_compilation/b3841.d-mixin-32(32): Warning: `int %= float` is performing truncating conversion
20 fail_compilation/b3841.d-mixin-32(32): Warning: `long %= double` is performing truncating conversion
21 Error: warnings are treated as errors
22 Use -wi if you wish to treat warnings only as informational.
23 ---
24 */
25
26
27 void f(string op, LHS, RHS)()
28 {
29 // pragma(msg, LHS, " += ", RHS);
30 LHS a;
31 RHS b;
32 mixin("a "~op~" b;");
33 }
34
35 template Ops(T...)
36 {
37 alias Ops = T;
38 }
39
40 void main()
41 {
42 foreach (string op; Ops!("+=", "-=", "*=", "/=", "%="))
43 {
44 // OK
45 f!(op, int, int)();
46 f!(op, long, int)();
47 f!(op, long, short)();
48 f!(op, float, 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 // OK
62 f!("^^=", int, int)();
63 f!("^^=", long, int)();
64 f!("^^=", long, short)();
65 f!("^^=", float, long)();
66 f!("^^=", double, float)();
67 // Should that really be OK ?
68 f!("^^=", float, double)();
69 }