Debian Codegraph @

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

raw
1 // REQUIRED_ARGS: -w
2
3 /*
4 TEST_OUTPUT:
5 ---
6 fail_compilation/warn7444.d(22): Error: cannot implicitly convert expression `e` of type `int` to `int[]`
7 ---
8 */
9
10 void test7444()
11 {
12 int[2] sa;
13 int[] da;
14 int e;
15
16 {
17 // X: Changed accepts-invalid to rejects-invalid by this issue
18 // a: slice assignment
19 // b: element-wise assignment
20 sa = e; // X
21 sa[] = e; // b
22 da = e;
23 da[] = e; // b
24
25 // lhs is static array
26 sa = sa; // b == identity assign
27 sa = sa[]; // X
28 sa[] = sa; // X
29 sa[] = sa[]; // b
30
31 sa = da; // X
32 sa = da[]; // X
33 sa[] = da; // X
34 sa[] = da[]; // b
35
36 // lhs is dynamic array
37 da = sa; // X
38 da = sa[]; // a
39 da[] = sa; // X
40 da[] = sa[]; // b
41
42 da = da; // a == identity assign
43 da = da[]; // a
44 da[] = da; // X
45 da[] = da[]; // b
46 }
47 }
48
49 /*
50 TEST_OUTPUT:
51 ---
52 No warning
53 ---
54 */
55
56 void test10214()
57 {
58 bool[1] arr;
59 arr = 0;
60 pragma(msg, "No warning");
61 }
62
63 /*
64 TEST_OUTPUT:
65 ---
66 No warning
67 ---
68 */
69
70 struct S11228
71 {
72 int[2] ii;
73 alias ii this;
74 }
75 void test11228()
76 {
77 S11228 s;
78 int[2] ii;
79 ii = s.ii; // OK
80 ii = s; // OK <- Warning
81 pragma(msg, "No warning");
82 }