Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag12063.d(21): Error: cannot check `diag12063.Bar.b` value for overflow
5 fail_compilation/diag12063.d(18): Error: no property `max` for type `Foo`, perhaps `import std.algorithm;` is needed?
6 fail_compilation/diag12063.d(21): Error: cannot generate value for `diag12063.Bar.b`
7 fail_compilation/diag12063.d(21): Error: operator `+` is not defined for type `Bar`
8 fail_compilation/diag12063.d(16): perhaps overload the operator with `auto opBinary(string op : "+")(int rhs) {}`
9 fail_compilation/diag12063.d(31): Error: cannot check `diag12063.b` value for overflow
10 fail_compilation/diag12063.d(31): Error: no operator `==` for type `S`
11 fail_compilation/diag12063.d(24): perhaps overload it with `bool opEquals(int other) const {}`
12 fail_compilation/diag12063.d(40): Error: enum member `diag12063.d` initialization with `__anonymous.c+1` causes overflow for type `Q`
13 ---
14 */
15
16 struct Foo {}
17
18 enum Bar : Foo
19 {
20 a = Foo(),
21 b // no max, can't +1
22 }
23
24 struct S {
25 S opBinary(string s: "+")(int) => this;
26 enum max = 1; // wrong type
27 }
28
29 enum {
30 a = S(),
31 b // can't do S() == 1
32 }
33
34 struct Q {
35 enum max = Q();
36 }
37
38 enum {
39 c = Q(),
40 d // overflow detected
41 }
42
43 struct R {
44 int i;
45 R opBinary(string s: "+")(int) => this;
46 enum max = R(1);
47 }
48
49 enum ER
50 {
51 e = R(),
52 f // OK
53 }