]>
Commit | Line | Data |
---|---|---|
c5e94699 IB |
1 | /************************************************************/ |
2 | ||
3 | /* | |
4 | TEST_OUTPUT: | |
5 | --- | |
6 | fail_compilation/traits.d(100): Error: `getTargetInfo` key `"not_a_target_info"` not supported by this implementation | |
7 | fail_compilation/traits.d(101): Error: string expected as argument of __traits `getTargetInfo` instead of `100` | |
8 | fail_compilation/traits.d(102): Error: expected 1 arguments for `getTargetInfo` but had 2 | |
9 | fail_compilation/traits.d(103): Error: expected 1 arguments for `getTargetInfo` but had 0 | |
10 | fail_compilation/traits.d(200): Error: undefined identifier `imports.nonexistent` | |
11 | fail_compilation/traits.d(201): Error: undefined identifier `imports.nonexistent` | |
12 | fail_compilation/traits.d(202): Error: expected 1 arguments for `isPackage` but had 0 | |
13 | fail_compilation/traits.d(203): Error: expected 1 arguments for `isModule` but had 0 | |
5fee5ec3 IB |
14 | fail_compilation/traits.d(300): Error: In expression `__traits(allMembers, float)` `float` can't have members |
15 | fail_compilation/traits.d(300): `float` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation | |
16 | fail_compilation/traits.d(306): Error: In expression `__traits(allMembers, TemplatedStruct)` struct `TemplatedStruct(T)` has no members | |
17 | fail_compilation/traits.d(306): `TemplatedStruct(T)` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation | |
18 | fail_compilation/traits.d(309): Error: In expression `__traits(derivedMembers, float)` `float` can't have members | |
19 | fail_compilation/traits.d(309): `float` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation | |
20 | fail_compilation/traits.d(316): Error: In expression `__traits(derivedMembers, TemplatedStruct)` struct `TemplatedStruct(T)` has no members | |
21 | fail_compilation/traits.d(316): `TemplatedStruct(T)` must evaluate to either a module, a struct, an union, a class, an interface or a template instantiation | |
22 | fail_compilation/traits.d(404): Error: function `traits.func1` circular reference in `__traits(GetCppNamespaces,...)` | |
23 | fail_compilation/traits.d(413): Error: function `traits.foo1.func1` circular reference in `__traits(GetCppNamespaces,...)` | |
c5e94699 IB |
24 | --- |
25 | */ | |
26 | ||
27 | #line 100 | |
28 | enum A1 = __traits(getTargetInfo, "not_a_target_info"); | |
29 | enum B1 = __traits(getTargetInfo, 100); | |
30 | enum C1 = __traits(getTargetInfo, "cppRuntimeLibrary", "bits"); | |
31 | enum D1 = __traits(getTargetInfo); | |
32 | ||
33 | #line 200 | |
34 | enum A2 = __traits(isPackage, imports.nonexistent); | |
35 | enum B2 = __traits(isModule, imports.nonexistent); | |
36 | enum C2 = __traits(isPackage); | |
37 | enum D2 = __traits(isModule); | |
5fee5ec3 IB |
38 | |
39 | interface Interface {} | |
40 | struct TemplatedStruct(T) {} | |
41 | struct Struct {} | |
42 | union Union {} | |
43 | class Class {} | |
44 | ||
45 | #line 300 | |
46 | enum AM0 = __traits(allMembers, float); // compile error | |
47 | enum AM1 = __traits(allMembers, Struct); // no error | |
48 | enum AM2 = __traits(allMembers, Union); // no error | |
49 | enum AM3 = __traits(allMembers, Class); // no error | |
50 | enum AM4 = __traits(allMembers, Interface); // no error | |
51 | enum AM5 = __traits(allMembers, TemplatedStruct!float); // no error | |
52 | enum AM6 = __traits(allMembers, TemplatedStruct); // compile error | |
53 | enum AM7 = __traits(allMembers, mixin(__MODULE__)); // no error | |
54 | ||
55 | enum DM0 = __traits(derivedMembers, float); // compile error | |
56 | enum DM1 = __traits(derivedMembers, Struct); // no error | |
57 | enum DM2 = __traits(derivedMembers, Struct); // no error | |
58 | enum DM3 = __traits(derivedMembers, Union); // no error | |
59 | enum DM4 = __traits(derivedMembers, Class); // no error | |
60 | enum DM5 = __traits(derivedMembers, Interface); // no error | |
61 | enum DM6 = __traits(derivedMembers, TemplatedStruct!float); // no error | |
62 | enum DM7 = __traits(derivedMembers, TemplatedStruct); // compile error | |
63 | enum DM8 = __traits(derivedMembers, mixin(__MODULE__)); // no error | |
64 | ||
65 | #line 400 | |
66 | extern(C++, "bar") | |
67 | extern(C++, __traits(getCppNamespaces, func1)) void func () {} | |
68 | ||
69 | extern(C++, "foo") | |
70 | extern(C++, __traits(getCppNamespaces, func2)) void func1 () {} | |
71 | ||
72 | extern(C++, "foobar") | |
73 | extern(C++, __traits(getCppNamespaces, func)) void func2 () {} | |
74 | ||
75 | extern(C++, bar1) | |
76 | extern(C++, __traits(getCppNamespaces, foo1.func1)) void func () {} | |
77 | ||
78 | extern(C++, foo1) | |
79 | extern(C++, __traits(getCppNamespaces, foobar1.func2)) void func1 () {} | |
80 | ||
81 | extern(C++, foobar1) | |
82 | extern(C++, __traits(getCppNamespaces, bar1.func)) void func2 () {} | |
83 | ||
84 | /******************************************** | |
85 | https://issues.dlang.org/show_bug.cgi?id=21918 | |
86 | ||
87 | TEST_OUTPUT: | |
88 | --- | |
89 | fail_compilation/traits.d(501): Error: undefined identifier `T` | |
90 | fail_compilation/traits.d(502): while evaluating `pragma(msg, __traits(getParameterStorageClasses, yip, 0))` | |
91 | --- | |
92 | */ | |
93 | #line 500 | |
94 | ||
95 | auto yip(int f) {return T[];} | |
96 | pragma(msg, __traits(getParameterStorageClasses, yip, 0)); | |
97 | ||
98 | ||
99 | /******************************************** | |
100 | TEST_OUTPUT: | |
101 | --- | |
102 | fail_compilation/traits.d(602): Error: expected 1 arguments for `hasCopyConstructor` but had 0 | |
103 | fail_compilation/traits.d(602): while evaluating `pragma(msg, __traits(hasCopyConstructor))` | |
104 | fail_compilation/traits.d(603): Error: type expected as second argument of __traits `hasCopyConstructor` instead of `S()` | |
105 | fail_compilation/traits.d(603): while evaluating `pragma(msg, __traits(hasCopyConstructor, S()))` | |
106 | fail_compilation/traits.d(604): Error: expected 1 arguments for `hasPostblit` but had 0 | |
107 | fail_compilation/traits.d(604): while evaluating `pragma(msg, __traits(hasPostblit))` | |
108 | fail_compilation/traits.d(605): Error: type expected as second argument of __traits `hasPostblit` instead of `S()` | |
109 | fail_compilation/traits.d(605): while evaluating `pragma(msg, __traits(hasPostblit, S()))` | |
110 | --- | |
111 | */ | |
112 | #line 600 | |
113 | ||
114 | struct S { this (ref S rhs) {} } | |
115 | pragma(msg, __traits(hasCopyConstructor)); | |
116 | pragma(msg, __traits(hasCopyConstructor, S())); | |
117 | pragma(msg, __traits(hasPostblit)); | |
118 | pragma(msg, __traits(hasPostblit, S())); |