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

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

Final testcases?

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1#include <stdio.h>
2typedef struct some_struct_pointer * PTYPE;
3
4/*
5 * Function and method declarations.
6 * Checks mangling.
7 */
8
9/* No underscore, No mangling. */
10extern "C" void _Optlink ExternCVoid(int a, int b, int c, int d);
11extern "C" void * _Optlink ExternCPVoid(int a, int b, int c, int d);
12extern "C" int _Optlink ExternCInt(int a, int b, int c, int d);
13extern "C" PTYPE _Optlink ExternCPType(int a, int b, int c, int d);
14
15/* No underscore, No mangling. */
16void _Optlink Void(int a, int b, int c, int d);
17void * _Optlink PVoid(int a, int b, int c, int d);
18int _Optlink Int(int a, int b, int c, int d);
19PTYPE _Optlink PType(int a, int b, int c, int d);
20
21
22/* Members are mangled. */
23class foo
24{
25public:
26static void _Optlink StaticMemberVoid(int a, int b, int c, int d);
27static void * _Optlink StaticMemberPVoid(int a, int b, int c, int d);
28static int _Optlink StaticMemberInt(int a, int b, int c, int d);
29static 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 */
37void _Optlink MemberVoid(int a, int b, int c, int d);
38void * _Optlink MemberPVoid(int a, int b, int c, int d);
39int _Optlink MemberInt(int a, int b, int c, int d);
40PTYPE _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 */
48typedef void _Optlink Typedef1Void(int a, int b, int c, int d);
49typedef void * _Optlink Typedef1PVoid(int a, int b, int c, int d);
50typedef int _Optlink Typedef1Int(int a, int b, int c, int d);
51typedef PTYPE _Optlink Typedef1PType(int a, int b, int c, int d);
52
53typedef void (_Optlink Typedef2Void)(int a, int b, int c, int d);
54typedef void * (_Optlink Typedef2PVoid)(int a, int b, int c, int d);
55typedef int (_Optlink Typedef2Int)(int a, int b, int c, int d);
56typedef PTYPE (_Optlink Typedef2PType)(int a, int b, int c, int d);
57
58typedef void (* _Optlink PTypedef1Void)(int a, int b, int c, int d);
59typedef void * (* _Optlink PTypedef1PVoid)(int a, int b, int c, int d);
60typedef int (* _Optlink PTypedef1Int)(int a, int b, int c, int d);
61typedef PTYPE (* _Optlink PTypedef1PType)(int a, int b, int c, int d);
62
63/* Alternate writing which should have the same effect I think... */
64typedef void (_Optlink * PTypedef2Void)(int a, int b, int c, int d);
65typedef void * (_Optlink * PTypedef2PVoid)(int a, int b, int c, int d);
66typedef int (_Optlink * PTypedef2Int)(int a, int b, int c, int d);
67typedef PTYPE (_Optlink * PTypedef2PType)(int a, int b, int c, int d);
68
69
70/*
71 * Structures.
72 * Should not cause warnings.
73 */
74typedef 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
90extern "C" int DoC(void);
91int 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
Note: See TracBrowser for help on using the repository browser.