MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / test20998.d
blob2e137ab76316bb3f181cf696f02a9483b213123b
1 // https://issues.dlang.org/show_bug.cgi?id=20998
2 /*
3 REQUIRED_ARGS: -verrors=context
4 TEST_OUTPUT:
5 ---
6 fail_compilation/test20998.d(76): Error: undefined identifier `invalid`
7 X x = { invalid, 2, "asd" };
9 fail_compilation/test20998.d(76): Error: too many initializers for `X` with 2 fields
10 X x = { invalid, 2, "asd" };
12 fail_compilation/test20998.d(83): Error: cannot implicitly convert expression `"a"` of type `string` to `int`
13 X2 x2 = { ptr: null, "a", ptr: 2, 444 };
15 fail_compilation/test20998.d(83): Error: duplicate initializer for field `ptr`
16 X2 x2 = { ptr: null, "a", ptr: 2, 444 };
18 fail_compilation/test20998.d(83): Error: too many initializers for `X2` with 3 fields
19 X2 x2 = { ptr: null, "a", ptr: 2, 444 };
21 fail_compilation/test20998.d(90): Error: overlapping initialization for field `ptr` and `x`
22 X3 x3 = { ptr: null, "a", ptr: 2, 444 };
24 fail_compilation/test20998.d(90): Error: cannot implicitly convert expression `"a"` of type `string` to `int`
25 X3 x3 = { ptr: null, "a", ptr: 2, 444 };
27 fail_compilation/test20998.d(90): Error: duplicate initializer for field `ptr`
28 X3 x3 = { ptr: null, "a", ptr: 2, 444 };
30 fail_compilation/test20998.d(90): Error: too many initializers for `X3` with 3 fields
31 X3 x3 = { ptr: null, "a", ptr: 2, 444 };
33 fail_compilation/test20998.d(98): Error: field `X4.ptr` cannot assign to misaligned pointers in `@safe` code
34 X4 x4 = { ptr: null, "a", 444, ptr: 2, true };
36 fail_compilation/test20998.d(98): Error: cannot implicitly convert expression `"a"` of type `string` to `int`
37 X4 x4 = { ptr: null, "a", 444, ptr: 2, true };
39 fail_compilation/test20998.d(98): Error: too many initializers for `X4` with 2 fields
40 X4 x4 = { ptr: null, "a", 444, ptr: 2, true };
42 fail_compilation/test20998.d(102): called from here: `test()`
43 auto e = test();
45 fail_compilation/test20998.d(104): Error: cannot implicitly convert expression `1` of type `int` to `void*`
46 X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 };
48 fail_compilation/test20998.d(104): Error: duplicate initializer for field `ptr`
49 X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 };
51 fail_compilation/test20998.d(104): Error: duplicate initializer for field `ptr`
52 X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 };
54 fail_compilation/test20998.d(104): Error: too many initializers for `X2` with 3 fields
55 X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 };
57 fail_compilation/test20998.d(107): Error: too many initializers for `X2` with 3 fields
58 X2 c6 = { null, 2, true, null };
60 fail_compilation/test20998.d(116): Error: cannot implicitly convert expression `1` of type `int` to `immutable(char*)`
61 immutable Struct iStruct = {1, &ch};
63 fail_compilation/test20998.d(116): Error: too many initializers for `Struct` with 1 field
64 immutable Struct iStruct = {1, &ch};
66 fail_compilation/test20998.d(120): called from here: `test2()`
67 auto t = test2();
69 ---
72 struct X {
73 void* ptr;
74 int x;
76 X x = { invalid, 2, "asd" };
78 struct X2 {
79 void* ptr;
80 int x;
81 bool y;
83 X2 x2 = { ptr: null, "a", ptr: 2, 444 };
85 union X3 {
86 void* ptr;
87 int x;
88 bool y;
90 X3 x3 = { ptr: null, "a", ptr: 2, 444 };
92 int test() @safe
94 align (1) struct X4 {
95 void* ptr;
96 int x;
98 X4 x4 = { ptr: null, "a", 444, ptr: 2, true };
99 return 0;
102 auto e = test();
104 X2 a5 = { ptr: 1, ptr: 2, ptr: 444, ptr: 555 };
105 X2 b5 = { ptr: null, y: true };
106 X2 c5 = { x: 2, true, ptr: null };
107 X2 c6 = { null, 2, true, null };
109 struct Struct {
110 char* chptr;
113 int test2()
115 char ch = 'd';
116 immutable Struct iStruct = {1, &ch};
117 return 0;
120 auto t = test2();