source: branches/libc-0.6/testcase/570main.cpp@ 3780

Last change on this file since 3780 was 1231, checked in by bird, 22 years ago

found a little problem.

  • Property cvs2svn:cvs-rev set to 1.8
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.2 KB
Line 
1/* $Id: 570main.cpp 1231 2004-02-12 15:00:11Z bird $ */
2/** @file
3 *
4 * _System declaration and definition testcases.
5 *
6 * InnoTek Systemberatung GmbH confidential
7 *
8 * Copyright (c) 2003 InnoTek Systemberatung GmbH
9 * Author: knut st. osmundsen <bird-srcspam@anduin.net>
10 *
11 * All Rights Reserved
12 *
13 */
14#include <stdio.h>
15typedef struct some_struct_pointer * PTYPE;
16
17/*
18 * Function and method declarations.
19 * Checks mangling.
20 */
21
22/* No underscore, No mangling. */
23extern "C" void _System ExternCVoid(int a, int b, int c, int d);
24extern "C" void * _System ExternCPVoid(int a, int b, int c, int d);
25extern "C" int _System ExternCInt(int a, int b, int c, int d);
26extern "C" PTYPE _System ExternCPType(int a, int b, int c, int d);
27
28/* No underscore, No mangling. */
29void _System Void(int a, int b, int c, int d);
30void * _System PVoid(int a, int b, int c, int d);
31int _System Int(int a, int b, int c, int d);
32PTYPE _System PType(int a, int b, int c, int d);
33
34
35/* Members are mangled. */
36class foo
37{
38public:
39static void _System StaticMemberVoid(int a, int b, int c, int d);
40static void * _System StaticMemberPVoid(int a, int b, int c, int d);
41static int _System StaticMemberInt(int a, int b, int c, int d);
42static PTYPE _System StaticMemberPType(int a, int b, int c, int d);
43
44/* VAC365 allows this too, and actually mangles the
45 * calling convention into the name.
46 * _System: MemberVoid__3fooF__l2_v
47 * default: MemberVoid__3fooFv
48 * We don't need to support this, it's just a curiosity.
49 */
50void _System MemberVoid(int a, int b, int c, int d);
51void * _System MemberPVoid(int a, int b, int c, int d);
52int _System MemberInt(int a, int b, int c, int d);
53PTYPE _System MemberPType(int a, int b, int c, int d);
54};
55
56
57/*
58 * Typedefs.
59 * Checks that there is not warnings on these.
60 */
61typedef void _System Typedef1Void(int a, int b, int c, int d);
62typedef void * _System Typedef1PVoid(int a, int b, int c, int d);
63typedef int _System Typedef1Int(int a, int b, int c, int d);
64typedef PTYPE _System Typedef1PType(int a, int b, int c, int d);
65
66typedef void (_System Typedef2Void)(int a, int b, int c, int d);
67typedef void * (_System Typedef2PVoid)(int a, int b, int c, int d);
68typedef int (_System Typedef2Int)(int a, int b, int c, int d);
69typedef PTYPE (_System Typedef2PType)(int a, int b, int c, int d);
70
71typedef void (* _System PTypedef1Void)(int a, int b, int c, int d);
72typedef void * (* _System PTypedef1PVoid)(int a, int b, int c, int d);
73typedef int (* _System PTypedef1Int)(int a, int b, int c, int d);
74typedef PTYPE (* _System PTypedef1PType)(int a, int b, int c, int d);
75
76/* Alternate writing which should have the same effect I think... */
77typedef void (_System * PTypedef2Void)(int a, int b, int c, int d);
78typedef void * (_System * PTypedef2PVoid)(int a, int b, int c, int d);
79typedef int (_System * PTypedef2Int)(int a, int b, int c, int d);
80typedef PTYPE (_System * PTypedef2PType)(int a, int b, int c, int d);
81
82
83/*
84 * Structures.
85 * Should not cause warnings.
86 */
87typedef struct VFT
88{
89 void (* _System PStructMemberVoid)(int a, int b, int c, int d);
90 void * (* _System PStructMemberPVoid)(int a, int b, int c, int d);
91 int (* _System PStructMemberInt)(int a, int b, int c, int d);
92 PTYPE (* _System PStructMemberPType)(int a, int b, int c, int d);
93
94 /* Alternate writing which should have the same effect I think... */
95 void ( _System * PStructMember2Void)(int a, int b, int c, int d);
96 void * ( _System * PStructMember2PVoid)(int a, int b, int c, int d);
97 int ( _System * PStructMember2Int)(int a, int b, int c, int d);
98 PTYPE ( _System * PStructMember2PType)(int a, int b, int c, int d);
99
100} VFT, *PVFT;
101
102
103/*
104 * Variables
105 */
106void (* _System PVar1Void)(int a, int b, int c, int d);
107void * (* _System PVar1PVoid)(int a, int b, int c, int d);
108int (* _System PVar1Int)(int a, int b, int c, int d);
109PTYPE (* _System PVar1PType)(int a, int b, int c, int d);
110
111/* Alternate writing which should have the same effect I think... */
112void (_System * PVar2Void)(int a, int b, int c, int d);
113void * (_System * PVar2PVoid)(int a, int b, int c, int d);
114int (_System * PVar2Int)(int a, int b, int c, int d);
115PTYPE (_System * PVar2PType)(int a, int b, int c, int d);
116
117
118/*
119 * Parameters.
120 */
121int ParamArgs(
122 void (* _System pfn1Void)(int a, int b, int c, int d),
123 void * (* _System pfn1PVoid)(int a, int b, int c, int d),
124 int (* _System pfn1Int)(int a, int b, int c, int d),
125 PTYPE (* _System pfn1PType)(int a, int b, int c, int d),
126 void (_System * pfn2Void)(int a, int b, int c, int d),
127 void * (_System * pfn2PVoid)(int a, int b, int c, int d),
128 int (_System * pfn2Int)(int a, int b, int c, int d),
129 PTYPE (_System * pfn2PType)(int a, int b, int c, int d)
130 )
131{
132 pfn1Void(1,2,3,4);
133 pfn1PVoid(1,2,3,4);
134 pfn1Int(1,2,3,4);
135 pfn1PType(1,2,3,4);
136
137 pfn2Void(1,2,3,4);
138 pfn2PVoid(1,2,3,4);
139 pfn2Int(1,2,3,4);
140 pfn2PType(1,2,3,4);
141 return 0;
142}
143
144extern void _System glutDisplayFunc1(void (* _System pfn)(void)); /* TODO make this work without the pfn!!! */
145extern void _System glutDisplayFunc2(void (_System *)(void));
146
147
148extern "C" int DoC(void);
149int main(void)
150{
151 static VFT vft = {Void, PVoid, Int, PType,
152 Void, PVoid, Int, PType};
153
154 static Typedef1Void * pfnTypedef1Void = Void;
155 static Typedef1PVoid * pfnTypedef1PVoid = PVoid;
156 static Typedef1Int * pfnTypedef1Int = Int;
157 static Typedef1PType * pfnTypedef1PType = PType;
158
159 static Typedef2Void * pfnTypedef2Void = Void;
160 static Typedef2PVoid * pfnTypedef2PVoid = PVoid;
161 static Typedef2Int * pfnTypedef2Int = Int;
162 static Typedef2PType * pfnTypedef2PType = PType;
163
164 static PTypedef1Void pfnPTypedef1Void = Void;
165 static PTypedef1PVoid pfnPTypedef1PVoid = PVoid;
166 static PTypedef1Int pfnPTypedef1Int = Int;
167 static PTypedef1PType pfnPTypedef1PType = PType;
168
169 static PTypedef2Void pfnPTypedef2Void = Void;
170 static PTypedef2PVoid pfnPTypedef2PVoid = PVoid;
171 static PTypedef2Int pfnPTypedef2Int = Int;
172 static PTypedef2PType pfnPTypedef2PType = PType;
173
174 PVar1Void = Void;
175 PVar1PVoid = PVoid;
176 PVar1Int = Int;
177 PVar1PType = PType;
178
179 PVar2Void = Void;
180 PVar2PVoid = PVoid;
181 PVar2Int = Int;
182 PVar2PType = PType;
183
184
185 /* extern functions */
186 ExternCVoid(1,2,3,4);
187 ExternCPVoid(1,2,3,4);
188 ExternCInt(1,2,3,4);
189 ExternCPType(1,2,3,4);
190
191 Void(1,2,3,4);
192 PVoid(1,2,3,4);
193 Int(1,2,3,4);
194 PType(1,2,3,4);
195
196 /* class */
197 foo::StaticMemberVoid(1,2,3,4);
198 foo::StaticMemberPVoid(1,2,3,4);
199 foo::StaticMemberInt(1,2,3,4);
200 foo::StaticMemberPType(1,2,3,4);
201
202 foo obj;
203 obj.MemberVoid(1,2,3,4);
204 obj.MemberPVoid(1,2,3,4);
205 obj.MemberInt(1,2,3,4);
206 obj.MemberPType(1,2,3,4);
207
208 /* typedefs */
209 pfnTypedef1Void(1,2,3,4);
210 pfnTypedef1PVoid(1,2,3,4);
211 pfnTypedef1Int(1,2,3,4);
212 pfnTypedef1PType(1,2,3,4);
213
214 pfnTypedef2Void(1,2,3,4);
215 pfnTypedef2PVoid(1,2,3,4);
216 pfnTypedef2Int(1,2,3,4);
217 pfnTypedef2PType(1,2,3,4);
218
219 pfnPTypedef1Void(1,2,3,4);
220 pfnPTypedef1PVoid(1,2,3,4);
221 pfnPTypedef1Int(1,2,3,4);
222 pfnPTypedef1PType(1,2,3,4);
223
224 pfnPTypedef2Void(1,2,3,4);
225 pfnPTypedef2PVoid(1,2,3,4);
226 pfnPTypedef2Int(1,2,3,4);
227 pfnPTypedef2PType(1,2,3,4);
228
229
230 /* structs */
231 vft.PStructMemberVoid(1,2,3,4);
232 vft.PStructMemberPVoid(1,2,3,4);
233 vft.PStructMemberInt(1,2,3,4);
234 vft.PStructMemberPType(1,2,3,4);
235
236 vft.PStructMember2Void(1,2,3,4);
237 vft.PStructMember2PVoid(1,2,3,4);
238 vft.PStructMember2Int(1,2,3,4);
239 vft.PStructMember2PType(1,2,3,4);
240
241 /* variables */
242 PVar1Void(1,2,3,4);
243 PVar1PVoid(1,2,3,4);
244 PVar1Int(1,2,3,4);
245 PVar1PType(1,2,3,4);
246
247 PVar2Void(1,2,3,4);
248 PVar2PVoid(1,2,3,4);
249 PVar2Int(1,2,3,4);
250 PVar2PType(1,2,3,4);
251
252 /* parameters */
253 ParamArgs(Void, PVoid, Int, PType,
254 Void, PVoid, Int, PType);
255
256
257 /* test C stuff */
258 DoC();
259
260 printf("Successfully executed _System testcase (assumed).\n");
261 return 0;
262}
263
Note: See TracBrowser for help on using the repository browser.