]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/fail12604.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail12604.d
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail12604.d(14): Error: mismatched array lengths, 1 and 3
5 fail_compilation/fail12604.d(15): Error: mismatched array lengths, 1 and 3
6 fail_compilation/fail12604.d(17): Error: mismatched array lengths, 1 and 3
7 fail_compilation/fail12604.d(18): Error: mismatched array lengths, 1 and 3
8 fail_compilation/fail12604.d(20): Error: cannot implicitly convert expression `[65536]` of type `int[]` to `short[]`
9 fail_compilation/fail12604.d(21): Error: cannot implicitly convert expression `[65536, 2, 3]` of type `int[]` to `short[]`
10 ---
11 */
12 void main()
13 {
14 int[1] a1 = [1,2,3];
15 short[1] a2 = [1,2,3];
16
17 int[1] b1; b1 = [1,2,3];
18 short[1] b2; b2 = [1,2,3];
19
20 short[1] c = [65536];
21 short[1] d = [65536,2,3];
22 }
23
24 /*
25 TEST_OUTPUT:
26 ---
27 fail_compilation/fail12604.d(39): Error: mismatched array lengths, 2 and 3
28 fail_compilation/fail12604.d(40): Error: mismatched array lengths, 2 and 3
29 fail_compilation/fail12604.d(41): Error: mismatched array lengths, 2 and 3
30 fail_compilation/fail12604.d(42): Error: mismatched array lengths, 2 and 3
31 fail_compilation/fail12604.d(43): Error: mismatched array lengths, 2 and 3
32 fail_compilation/fail12604.d(44): Error: mismatched array lengths, 2 and 3
33 fail_compilation/fail12604.d(45): Error: mismatched array lengths, 2 and 3
34 fail_compilation/fail12604.d(46): Error: mismatched array lengths, 2 and 3
35 ---
36 */
37 void test12606a() // AssignExp::semantic
38 {
39 uint[2] a1 = [1, 2, 3][];
40 ushort[2] a2 = [1, 2, 3][];
41 uint[2] a3 = [1, 2, 3][0 .. 3];
42 ushort[2] a4 = [1, 2, 3][0 .. 3];
43 a1 = [1, 2, 3][];
44 a2 = [1, 2, 3][];
45 a3 = [1, 2, 3][0 .. 3];
46 a4 = [1, 2, 3][0 .. 3];
47 }
48
49 /*
50 TEST_OUTPUT:
51 ---
52 fail_compilation/fail12604.d(60): Error: mismatched array lengths, 2 and 3
53 fail_compilation/fail12604.d(61): Error: mismatched array lengths, 2 and 3
54 fail_compilation/fail12604.d(62): Error: mismatched array lengths, 2 and 3
55 fail_compilation/fail12604.d(63): Error: mismatched array lengths, 2 and 3
56 ---
57 */
58 void test12606b() // ExpInitializer::semantic
59 {
60 static uint[2] a1 = [1, 2, 3][];
61 static uint[2] a2 = [1, 2, 3][0 .. 3];
62 static ushort[2] a3 = [1, 2, 3][];
63 static ushort[2] a4 = [1, 2, 3][0 .. 3];
64 }
65
66 /*
67 TEST_OUTPUT:
68 ---
69 fail_compilation/fail12604.d(77): Error: mismatched array lengths, 4 and 3
70 fail_compilation/fail12604.d(78): Error: mismatched array lengths, 4 and 3
71 ---
72 */
73 void testc()
74 {
75 int[4] sa1;
76 int[3] sa2;
77 sa1[0..4] = [1,2,3];
78 sa1[0..4] = sa2;
79 }