source: trunk/testcase/572main.cpp@ 837

Last change on this file since 837 was 639, checked in by bird, 22 years ago

Extended testcase with variable declaration.

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