Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/issue22820.d(138): Error: upper and lower bounds are needed to slice a pointer
5 fail_compilation/issue22820.d(138): pointer `s1` points to an aggregate that defines an `opIndex`, perhaps you meant `(*s1)[]`
6 fail_compilation/issue22820.d(139): Error: upper and lower bounds are needed to slice a pointer
7 fail_compilation/issue22820.d(139): pointer `s2` points to an aggregate that defines an `opSlice`, perhaps you meant `(*s2)[]`
8 fail_compilation/issue22820.d(140): Error: upper and lower bounds are needed to slice a pointer
9 fail_compilation/issue22820.d(140): pointer `s3` points to an aggregate that defines an `opIndex`, perhaps you meant `(*s3)[]`
10 fail_compilation/issue22820.d(141): Error: upper and lower bounds are needed to slice a pointer
11 fail_compilation/issue22820.d(141): pointer `cp` points to an aggregate that defines an `opIndex`, perhaps you meant `(*cp)[]`
12 fail_compilation/issue22820.d(142): Error: upper and lower bounds are needed to slice a pointer
13 fail_compilation/issue22820.d(142): pointer `e` points to an aggregate that defines an `opIndex`, perhaps you meant `(*e)[]`
14 ---
15 */
16
17 #line 100
18
19 // normal functions
20 struct S1 {
21 int[] opIndex() { return a; }
22 int[] a;
23 }
24
25 // opSlice alternative
26 struct S2 {
27 int[] opSlice() { return a; }
28 int[] a;
29 }
30
31 // templates
32 struct S3 {
33 int[] opIndex()() { return a; }
34 int[] a;
35 }
36
37 class C {
38 int[] opIndex()() { return a; }
39 int[] a;
40 }
41
42 enum E : S1
43 {
44 a = S1([1])
45 }
46
47 void main() {
48 S1* s1 = new S1;
49 S2* s2 = new S2;
50 S3* s3 = new S3;
51 C c = new C;
52 C* cp = &c;
53 E* e = new E;
54 int* p;
55
56 p = s1[].ptr;
57 p = s2[].ptr;
58 p = s3[].ptr;
59 p = cp[].ptr;
60 p = e[].ptr;
61
62 p = (*s1)[].ptr;
63 p = (*s2)[].ptr;
64 p = (*s3)[].ptr;
65 p = (*cp)[].ptr;
66 p = (*e)[].ptr;
67 }