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

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

Extended to third calling convention syntax.

  • Property cvs2svn:cvs-rev set to 1.5
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 11.1 KB
Line 
1/* $Id: 572main.cpp 1232 2004-02-12 15:21:45Z 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 <[email protected]>
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#ifdef __EMX__
73typedef void _Optlink (Typedef3Void)(int a, int b, int c, int d);
74typedef void * _Optlink (Typedef3PVoid)(int a, int b, int c, int d);
75typedef int _Optlink (Typedef3Int)(int a, int b, int c, int d);
76typedef PTYPE _Optlink (Typedef3PType)(int a, int b, int c, int d);
77#endif
78
79typedef void (* _Optlink PTypedef1Void)(int a, int b, int c, int d);
80typedef void * (* _Optlink PTypedef1PVoid)(int a, int b, int c, int d);
81typedef int (* _Optlink PTypedef1Int)(int a, int b, int c, int d);
82typedef PTYPE (* _Optlink PTypedef1PType)(int a, int b, int c, int d);
83
84/* Alternate writing which should have the same effect I think... */
85typedef void (_Optlink * PTypedef2Void)(int a, int b, int c, int d);
86typedef void * (_Optlink * PTypedef2PVoid)(int a, int b, int c, int d);
87typedef int (_Optlink * PTypedef2Int)(int a, int b, int c, int d);
88typedef PTYPE (_Optlink * PTypedef2PType)(int a, int b, int c, int d);
89#ifdef __EMX__
90/* Alternate writing which should have the same effect I think... */
91typedef void _Optlink (* PTypedef3Void)(int a, int b, int c, int d);
92typedef void * _Optlink (* PTypedef3PVoid)(int a, int b, int c, int d);
93typedef int _Optlink (* PTypedef3Int)(int a, int b, int c, int d);
94typedef PTYPE _Optlink (* PTypedef3PType)(int a, int b, int c, int d);
95#endif
96
97
98/*
99 * Structures.
100 * Should not cause warnings.
101 */
102typedef struct VFT
103{
104 void (* _Optlink PStructMemberVoid)(int a, int b, int c, int d);
105 void * (* _Optlink PStructMemberPVoid)(int a, int b, int c, int d);
106 int (* _Optlink PStructMemberInt)(int a, int b, int c, int d);
107 PTYPE (* _Optlink PStructMemberPType)(int a, int b, int c, int d);
108
109 /* Alternate writing which should have the same effect I think... */
110 void (_Optlink * PStructMember2Void)(int a, int b, int c, int d);
111 void * (_Optlink * PStructMember2PVoid)(int a, int b, int c, int d);
112 int (_Optlink * PStructMember2Int)(int a, int b, int c, int d);
113 PTYPE (_Optlink * PStructMember2PType)(int a, int b, int c, int d);
114#ifdef __EMX__
115 /* Alternate writing which should have the same effect I think... */
116 void _Optlink (* PStructMember3Void)(int a, int b, int c, int d);
117 void * _Optlink (* PStructMember3PVoid)(int a, int b, int c, int d);
118 int _Optlink (* PStructMember3Int)(int a, int b, int c, int d);
119 PTYPE _Optlink (* PStructMember3PType)(int a, int b, int c, int d);
120#endif
121
122} VFT, *PVFT;
123
124
125/*
126 * Variables
127 */
128void (* _Optlink PVar1Void)(int a, int b, int c, int d);
129void * (* _Optlink PVar1PVoid)(int a, int b, int c, int d);
130int (* _Optlink PVar1Int)(int a, int b, int c, int d);
131PTYPE (* _Optlink PVar1PType)(int a, int b, int c, int d);
132
133/* Alternate writing which should have the same effect I think... */
134void (_Optlink * PVar2Void)(int a, int b, int c, int d);
135void * (_Optlink * PVar2PVoid)(int a, int b, int c, int d);
136int (_Optlink * PVar2Int)(int a, int b, int c, int d);
137PTYPE (_Optlink * PVar2PType)(int a, int b, int c, int d);
138#ifdef __EMX__
139void _Optlink (* PVar3Void)(int a, int b, int c, int d);
140void * _Optlink (* PVar3PVoid)(int a, int b, int c, int d);
141int _Optlink (* PVar3Int)(int a, int b, int c, int d);
142PTYPE _Optlink (* PVar3PType)(int a, int b, int c, int d);
143#endif
144