1 | #include <stdio.h>
|
---|
2 | typedef struct some_struct_pointer * PTYPE;
|
---|
3 |
|
---|
4 | /*
|
---|
5 | * Function and method declarations.
|
---|
6 | * Checks mangling.
|
---|
7 | */
|
---|
8 |
|
---|
9 | /* No underscore, No mangling. */
|
---|
10 | extern "C" void _Optlink ExternCVoid(int a, int b, int c, int d);
|
---|
11 | extern "C" void * _Optlink ExternCPVoid(int a, int b, int c, int d);
|
---|
12 | extern "C" int _Optlink ExternCInt(int a, int b, int c, int d);
|
---|
13 | extern "C" PTYPE _Optlink ExternCPType(int a, int b, int c, int d);
|
---|
14 |
|
---|
15 | /* No underscore, No mangling. */
|
---|
16 | void _Optlink Void(int a, int b, int c, int d);
|
---|
17 | void * _Optlink PVoid(int a, int b, int c, int d);
|
---|
18 | int _Optlink Int(int a, int b, int c, int d);
|
---|
19 | PTYPE _Optlink PType(int a, int b, int c, int d);
|
---|
20 |
|
---|
21 |
|
---|
22 | /* Members are mangled. */
|
---|
23 | class foo
|
---|
24 | {
|
---|
25 | public:
|
---|
26 | static void _Optlink StaticMemberVoid(int a, int b, int c, int d);
|
---|
27 | static void * _Optlink StaticMemberPVoid(int a, int b, int c, int d);
|
---|
28 | static int _Optlink StaticMemberInt(int a, int b, int c, int d);
|
---|
29 | static PTYPE _Optlink StaticMemberPType(int a, int b, int c, int d);
|
---|
30 |
|
---|
31 | /* VAC365 allows this too, and actually mangles the
|
---|
32 | * calling convention into the name.
|
---|
33 | * _System: MemberVoid__3fooF__l2_v
|
---|
34 | * default: MemberVoid__3fooFv
|
---|
35 | * We don't need to support this, it's just a curiosity.
|
---|
36 | */
|
---|
37 | void _Optlink MemberVoid(int a, int b, int c, int d);
|
---|
38 | void * _Optlink MemberPVoid(int a, int b, int c, int d);
|
---|
39 | int _Optlink MemberInt(int a, int b, int c, int d);
|
---|
40 | PTYPE _Optlink MemberPType(int a, int b, int c, int d);
|
---|
41 | };
|
---|
42 |
|
---|
43 |
|
---|
44 | /*
|
---|
45 | * Typedefs.
|
---|
46 | * Checks that there is not warnings on these.
|
---|
47 | */
|
---|
48 | typedef void _Optlink Typedef1Void(int a, int b, int c, int d);
|
---|
49 | typedef void * _Optlink Typedef1PVoid(int a, int b, int c, int d);
|
---|
50 | typedef int _Optlink Typedef1Int(int a, int b, int c, int d);
|
---|
51 | typedef PTYPE _Optlink Typedef1PType(int a, int b, int c, int d);
|
---|
52 |
|
---|
53 | typedef void (_Optlink Typedef2Void)(int a, int b, int c, int d);
|
---|
54 | typedef void * (_Optlink Typedef2PVoid)(int a, int b, int c, int d);
|
---|
55 | typedef int (_Optlink Typedef2Int)(int a, int b, int c, int d);
|
---|
56 | typedef PTYPE (_Optlink Typedef2PType)(int a, int b, int c, int d);
|
---|
57 |
|
---|
58 | typedef void (* _Optlink PTypedef1Void)(int a, int b, int c, int d);
|
---|
59 | typedef void * (* _Optlink PTypedef1PVoid)(int a, int b, int c, int d);
|
---|
60 | typedef int (* _Optlink PTypedef1Int)(int a, int b, int c, int d);
|
---|
61 | typedef PTYPE (* _Optlink PTypedef1PType)(int a, int b, int c, int d);
|
---|
62 |
|
---|
63 | /* Alternate writing which should have the same effect I think... */
|
---|
64 | typedef void (_Optlink * PTypedef2Void)(int a, int b, int c, int d);
|
---|
65 | typedef void * (_Optlink * PTypedef2PVoid)(int a, int b, int c, int d);
|
---|
66 | typedef int (_Optlink * PTypedef2Int)(int a, int b, int c, int d);
|
---|
67 | typedef PTYPE (_Optlink * PTypedef2PType)(int a, int b, int c, int d);
|
---|
68 |
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * Structures.
|
---|
72 | * Should not cause warnings.
|
---|
73 | */
|
---|
74 | typedef struct VFT
|
---|
75 | {
|
---|
76 | void (* _Optlink PStructMemberVoid)(int a, int b, int c, int d);
|
---|
77 | void * (* _Optlink PStructMemberPVoid)(int a, int b, int c, int d);
|
---|
78 | int (* _Optlink PStructMemberInt)(int a, int b, int c, int d);
|
---|
79 | PTYPE (* _Optlink PStructMemberPType)(int a, int b, int c, int d);
|
---|
80 |
|
---|
81 | /* Alternate writing which should have the same effect I think... */
|
---|
82 | void (_Optlink * PStructMember2Void)(int a, int b, int c, int d);
|
---|
83 | void * (_Optlink * PStructMember2PVoid)(int a, int b, int c, int d);
|
---|
84 | int (_Optlink * PStructMember2Int)(int a, int b, int c, int d);
|
---|
85 | PTYPE (_Optlink * PStructMember2PType)(int a, int b, int c, int d);
|
---|
86 |
|
---|
87 | } VFT, *PVFT;
|
---|
88 |
|
---|
89 |
|
---|
90 | extern "C" int DoC(void);
|
---|
91 | int main(void)
|
---|
92 | {
|
---|
93 | static VFT vft = {Void, PVoid, Int, PType,
|
---|
94 | Void, PVoid, Int, PType};
|
---|
95 |
|
---|
96 | static Typedef1Void * pfnTypedef1Void = Void;
|
---|
97 | static Typedef1PVoid * pfnTypedef1PVoid = PVoid;
|
---|
98 | static Typedef1Int * pfnTypedef1Int = Int;
|
---|
99 | static Typedef1PType * pfnTypedef1PType = PType;
|
---|
100 |
|
---|
101 | static Typedef2Void * pfnTypedef2Void = Void;
|
---|
102 | static Typedef2PVoid * pfnTypedef2PVoid = PVoid;
|
---|
103 | static Typedef2Int * pfnTypedef2Int = Int;
|
---|
104 | static Typedef2PType * pfnTypedef2PType = PType;
|
---|
105 |
|
---|
106 | static PTypedef1Void pfnPTypedef1Void = Void;
|
---|
107 | static PTypedef1PVoid pfnPTypedef1PVoid = PVoid;
|
---|
108 | static PTypedef1Int pfnPTypedef1Int = Int;
|
---|
109 | static PTypedef1PType pfnPTypedef1PType = PType;
|
---|
110 |
|
---|
111 | static PTypedef2Void pfnPTypedef2Void = Void;
|
---|
112 | static PTypedef2PVoid pfnPTypedef2PVoid = PVoid;
|
---|
113 | static PTypedef2Int pfnPTypedef2Int = Int;
|
---|
114 | static PTypedef2PType pfnPTypedef2PType = PType;
|
---|
115 |
|
---|
116 | /* extern functions */
|
---|
117 | ExternCVoid(1,2,3,4);
|
---|
118 | ExternCPVoid(1,2,3,4);
|
---|
119 | ExternCInt(1,2,3,4);
|
---|
120 | ExternCPType(1,2,3,4);
|
---|
121 |
|
---|
122 | Void(1,2,3,4);
|
---|
123 | PVoid(1,2,3,4);
|
---|
124 | Int(1,2,3,4);
|
---|
125 | PType(1,2,3,4);
|
---|
126 |
|
---|
127 | /* class */
|
---|
128 | foo::StaticMemberVoid(1,2,3,4);
|
---|
129 | foo::StaticMemberPVoid(1,2,3,4);
|
---|
130 | foo::StaticMemberInt(1,2,3,4);
|
---|
131 | foo::StaticMemberPType(1,2,3,4);
|
---|
132 |
|
---|
133 | foo obj;
|
---|
134 | obj.MemberVoid(1,2,3,4);
|
---|
135 | obj.MemberPVoid(1,2,3,4);
|
---|
136 | obj.MemberInt(1,2,3,4);
|
---|
137 | obj.MemberPType(1,2,3,4);
|
---|
138 |
|
---|
139 | /* typedefs */
|
---|
140 | pfnTypedef1Void(1,2,3,4);
|
---|
141 | pfnTypedef1PVoid(1,2,3,4);
|
---|
142 | pfnTypedef1Int(1,2,3,4);
|
---|
143 | pfnTypedef1PType(1,2,3,4);
|
---|
144 |
|
---|
145 | pfnTypedef2Void(1,2,3,4);
|
---|
146 | pfnTypedef2PVoid(1,2,3,4);
|
---|
147 | pfnTypedef2Int(1,2,3,4);
|
---|
148 | pfnTypedef2PType(1,2,3,4);
|
---|
149 |
|
---|
150 | pfnPTypedef1Void(1,2,3,4);
|
---|
151 | pfnPTypedef1PVoid(1,2,3,4);
|
---|
152 | pfnPTypedef1Int(1,2,3,4);
|
---|
153 | pfnPTypedef1PType(1,2,3,4);
|
---|
154 |
|
---|
155 | pfnPTypedef2Void(1,2,3,4);
|
---|
156 | pfnPTypedef2PVoid(1,2,3,4);
|
---|
157 | pfnPTypedef2Int(1,2,3,4);
|
---|
158 | pfnPTypedef2PType(1,2,3,4);
|
---|
159 |
|
---|
160 |
|
---|
161 | /* structs */
|
---|
162 | vft.PStructMemberVoid(1,2,3,4);
|
---|
163 | vft.PStructMemberPVoid(1,2,3,4);
|
---|
164 | vft.PStructMemberInt(1,2,3,4);
|
---|
165 | vft.PStructMemberPType(1,2,3,4);
|
---|
166 |
|
---|
167 | vft.PStructMember2Void(1,2,3,4);
|
---|
168 | vft.PStructMember2PVoid(1,2,3,4);
|
---|
169 | vft.PStructMember2Int(1,2,3,4);
|
---|
170 | vft.PStructMember2PType(1,2,3,4);
|
---|
171 |
|
---|
172 | /* test C stuff */
|
---|
173 | DoC();
|
---|
174 |
|
---|
175 | printf("Successfully executed _Optlink testcase (assumed).\n");
|
---|
176 | return 0;
|
---|
177 | }
|
---|
178 |
|
---|