Debian Codegraph @

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

raw
1 /**
2 TEST_OUTPUT:
3 ---
4 fail_compilation/hexstring.d(30): Error: array cast from `string` to `ubyte[3][1]` is not supported at compile time
5 fail_compilation/hexstring.d(33): Error: cannot implicitly convert expression `"123F"` of type `string` to `immutable(ubyte[])`
6 fail_compilation/hexstring.d(37): Error: hex string length 1 must be a multiple of 2 to cast to `immutable(ushort[])`
7 fail_compilation/hexstring.d(38): Error: hex string length 3 must be a multiple of 4 to cast to `immutable(uint[])`
8 fail_compilation/hexstring.d(39): Error: hex string length 5 must be a multiple of 8 to cast to `immutable(ulong[])`
9 fail_compilation/hexstring.d(40): Error: array cast from `wstring` to `immutable(ulong[])` is not supported at compile time
10 fail_compilation/hexstring.d(40): perhaps remove postfix `w` from hex string
11 fail_compilation/hexstring.d(41): Error: array cast from `string` to `immutable(uint[])` is not supported at compile time
12 fail_compilation/hexstring.d(42): Error: array cast from `string` to `immutable(ushort[])` is not supported at compile time
13 fail_compilation/hexstring.d(43): Error: array cast from `string` to `immutable(uint[])` is not supported at compile time
14 fail_compilation/hexstring.d(43): perhaps remove postfix `c` from hex string
15 fail_compilation/hexstring.d(44): Error: hex string with `dstring` type needs to be multiple of 4 bytes, not 5
16 fail_compilation/hexstring.d(45): Error: cannot implicitly convert expression `x"11223344"d` of type `dstring` to `immutable(float[])`
17 fail_compilation/hexstring.d(46): Error: cannot implicitly convert expression `x"1122"w` of type `wstring` to `immutable(ubyte[])`
18 fail_compilation/hexstring.d(47): Error: array cast from `string` to `ubyte[3][1]` is not supported at compile time
19 fail_compilation/hexstring.d(48): Error: array cast from `string` to `ubyte[3][1][1]` is not supported at compile time
20 fail_compilation/hexstring.d(56): Error: array cast from `string` to `S[]` is not supported at compile time
21 fail_compilation/hexstring.d(32): Error: cannot implicitly convert expression `x"123F"` of type `string` to `ubyte[]`
22 ---
23 */
24 immutable ubyte[] s0 = x"123F";
25 static assert(s0[0] == 0x12);
26 static assert(s0[1] == 0x3F);
27 immutable byte[] s1 = x"123F";
28 enum E(X) = cast(X[]) x"AABBCCDD";
29 static assert(E!int[0] == 0xAABBCCDD);
30 immutable ubyte[3] s2 = cast(ubyte[3][1])x"FFAAFF";
31
32 ubyte[] f1 = x"123F";
33 immutable ubyte[] f2 = "123F";
34 immutable ubyte[] f3 = x"123F"c;
35 immutable ubyte[] f4 = cast(string) x"123F";
36
37 immutable ushort[] f5 = cast(immutable ushort[]) x"11";
38 immutable uint[] f6 = cast(immutable uint[]) x"112233";
39 immutable ulong[] f7 = cast(immutable ulong[]) x"1122334455";
40 immutable ulong[] f8 = cast(immutable ulong[]) x"11223344"w;
41 immutable uint[] f9 = cast(immutable uint[]) "ABCD";
42 immutable ushort[] f10 = cast(immutable ushort[]) (x"1122" ~ "");
43 immutable uint[] f11 = cast(immutable uint[]) x"AABBCCDD"c;
44 immutable uint[] f12 = x"1122334455"d;
45 immutable float[] f13 = x"11223344"d;
46 immutable ubyte[] f14 = x"1122"w;
47 immutable ubyte[3][1] f16 = cast(ubyte[3][1])x"FFBBFF";
48 immutable ubyte[3][1][1] f17 = cast(ubyte[3][1][1])x"FFCCFF";
49
50 // https://issues.dlang.org/show_bug.cgi?id=24832
51 struct S
52 {
53 ushort l0, l1, l2, l3, l4, l5;
54 }
55
56 immutable S[] returnValues = cast(S[]) x"FFFFFFFFFFFFFFFFFFFFFFFF";