Debian Codegraph @

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

raw
1 alias void FuncType();
2
3 struct Opaque;
4
5 template Tuple(T...) { alias T Tuple; }
6 alias Tuple!(int, int) TupleType;
7
8 /******************************************/
9 // return type
10
11 /*
12 TEST_OUTPUT:
13 ---
14 fail_compilation/fail12436.d(18): Error: functions cannot return a function
15 fail_compilation/fail12436.d(19): Error: functions cannot return a sequence (use `std.typecons.Tuple`)
16 ---
17 */
18 FuncType test1();
19 TupleType test2();
20
21 /*
22 TEST_OUTPUT:
23 ---
24 fail_compilation/fail12436.d(28): Error: functions cannot return opaque type `Opaque` by value
25 fail_compilation/fail12436.d(29): Error: functions cannot return opaque type `Opaque[1]` by value
26 ---
27 */
28 Opaque ret12436a(); // error
29 Opaque[1] ret12436b(); // error
30 Opaque* ret12436c(); // no error
31 Opaque[] ret12436d(); // no error
32 Opaque[]* ret12436e(); // no error
33
34 ref Opaque ret12436f(); // no error
35 ref Opaque[1] ret12436g(); // no error
36
37 /******************************************/
38 // parameter type
39
40 /*
41 TEST_OUTPUT:
42 ---
43 fail_compilation/fail12436.d(46): Error: cannot have parameter of function type `void()`
44 ---
45 */
46 void test3(FuncType) {}
47
48 /*
49 TEST_OUTPUT:
50 ---
51 fail_compilation/fail12436.d(55): Error: cannot have parameter of opaque type `Opaque` by value
52 fail_compilation/fail12436.d(56): Error: cannot have parameter of opaque type `Opaque[1]` by value
53 ---
54 */
55 void param12436a(Opaque); // error
56 void param12436b(Opaque[1]); // error
57 void param12436c(Opaque*); // no error
58 void param12436d(Opaque[]); // no error
59 void param12436e(Opaque[]*); // no error
60
61 void param12436f(ref Opaque); // no error
62 void param12436g(ref Opaque[1]); // no error
63 void param12436h(out Opaque); // no error
64 void param12436i(out Opaque[1]); // no error
65
66 /*
67 TEST_OUTPUT:
68 ---
69 fail_compilation/fail12436.d(75): Error: cannot have parameter of opaque type `A14906` by value
70 fail_compilation/fail12436.d(76): Error: cannot have parameter of opaque type `A14906[3]` by value
71 fail_compilation/fail12436.d(77): Error: cannot have parameter of opaque type `A14906[3][3]` by value
72 ---
73 */
74 enum A14906;
75 void f14906a(A14906) {}
76 void f14906b(A14906[3]) {}
77 void f14906c(A14906[3][3]) {}