| [601] | 1 | /* $Id: 570main.cpp 906 2003-12-15 20:33:09Z 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 | */ | 
|---|
| [600] | 14 | #include <stdio.h> | 
|---|
| [594] | 15 | typedef struct some_struct_pointer * PTYPE; | 
|---|
|  | 16 |  | 
|---|
|  | 17 | /* | 
|---|
|  | 18 | * Function and method declarations. | 
|---|
|  | 19 | * Checks mangling. | 
|---|
|  | 20 | */ | 
|---|
|  | 21 |  | 
|---|
|  | 22 | /* No underscore, No mangling. */ | 
|---|
| [599] | 23 | extern "C" void   _System   ExternCVoid(int a, int b, int c, int d); | 
|---|
|  | 24 | extern "C" void * _System   ExternCPVoid(int a, int b, int c, int d); | 
|---|
|  | 25 | extern "C" int    _System   ExternCInt(int a, int b, int c, int d); | 
|---|
|  | 26 | extern "C" PTYPE  _System   ExternCPType(int a, int b, int c, int d); | 
|---|
| [594] | 27 |  | 
|---|
|  | 28 | /* No underscore, No mangling. */ | 
|---|
| [599] | 29 | void    _System             Void(int a, int b, int c, int d); | 
|---|
|  | 30 | void *  _System             PVoid(int a, int b, int c, int d); | 
|---|
|  | 31 | int     _System             Int(int a, int b, int c, int d); | 
|---|
|  | 32 | PTYPE   _System             PType(int a, int b, int c, int d); | 
|---|
| [594] | 33 |  | 
|---|
|  | 34 |  | 
|---|
|  | 35 | /* Members are mangled. */ | 
|---|
|  | 36 | class foo | 
|---|
|  | 37 | { | 
|---|
|  | 38 | public: | 
|---|
| [599] | 39 | static void    _System      StaticMemberVoid(int a, int b, int c, int d); | 
|---|
|  | 40 | static void *  _System      StaticMemberPVoid(int a, int b, int c, int d); | 
|---|
|  | 41 | static int     _System      StaticMemberInt(int a, int b, int c, int d); | 
|---|
|  | 42 | static PTYPE   _System      StaticMemberPType(int a, int b, int c, int d); | 
|---|
| [594] | 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 | */ | 
|---|
| [599] | 50 | void           _System      MemberVoid(int a, int b, int c, int d); | 
|---|
|  | 51 | void *         _System      MemberPVoid(int a, int b, int c, int d); | 
|---|
|  | 52 | int            _System      MemberInt(int a, int b, int c, int d); | 
|---|
|  | 53 | PTYPE          _System      MemberPType(int a, int b, int c, int d); | 
|---|
| [594] | 54 | }; | 
|---|
|  | 55 |  | 
|---|
|  | 56 |  | 
|---|
|  | 57 | /* | 
|---|
|  | 58 | * Typedefs. | 
|---|
|  | 59 | * Checks that there is not warnings on these. | 
|---|
|  | 60 | */ | 
|---|
| [599] | 61 | typedef void    _System     Typedef1Void(int a, int b, int c, int d); | 
|---|
|  | 62 | typedef void *  _System     Typedef1PVoid(int a, int b, int c, int d); | 
|---|
|  | 63 | typedef int     _System     Typedef1Int(int a, int b, int c, int d); | 
|---|
|  | 64 | typedef PTYPE   _System     Typedef1PType(int a, int b, int c, int d); | 
|---|
| [594] | 65 |  | 
|---|
| [599] | 66 | typedef void    (_System    Typedef2Void)(int a, int b, int c, int d); | 
|---|
|  | 67 | typedef void *  (_System    Typedef2PVoid)(int a, int b, int c, int d); | 
|---|
|  | 68 | typedef int     (_System    Typedef2Int)(int a, int b, int c, int d); | 
|---|
|  | 69 | typedef PTYPE   (_System    Typedef2PType)(int a, int b, int c, int d); | 
|---|
| [594] | 70 |  | 
|---|
| [599] | 71 | typedef void    (* _System  PTypedef1Void)(int a, int b, int c, int d); | 
|---|
|  | 72 | typedef void *  (* _System  PTypedef1PVoid)(int a, int b, int c, int d); | 
|---|
|  | 73 | typedef int     (* _System  PTypedef1Int)(int a, int b, int c, int d); | 
|---|
|  | 74 | typedef PTYPE   (* _System  PTypedef1PType)(int a, int b, int c, int d); | 
|---|
| [594] | 75 |  | 
|---|
| [595] | 76 | /* Alternate writing which should have the same effect I think... */ | 
|---|
| [599] | 77 | typedef void    (_System *  PTypedef2Void)(int a, int b, int c, int d); | 
|---|
|  | 78 | typedef void *  (_System *  PTypedef2PVoid)(int a, int b, int c, int d); | 
|---|
|  | 79 | typedef int     (_System *  PTypedef2Int)(int a, int b, int c, int d); | 
|---|
|  | 80 | typedef PTYPE   (_System *  PTypedef2PType)(int a, int b, int c, int d); | 
|---|
| [594] | 81 |  | 
|---|
|  | 82 |  | 
|---|
|  | 83 | /* | 
|---|
|  | 84 | * Structures. | 
|---|
|  | 85 | * Should not cause warnings. | 
|---|
|  | 86 | */ | 
|---|
|  | 87 | typedef struct VFT | 
|---|
|  | 88 | { | 
|---|
| [599] | 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); | 
|---|
| [595] | 93 |  | 
|---|
|  | 94 | /* Alternate writing which should have the same effect I think... */ | 
|---|
| [599] | 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); | 
|---|
| [595] | 99 |  | 
|---|
| [594] | 100 | } VFT, *PVFT; | 
|---|
|  | 101 |  | 
|---|
|  | 102 |  | 
|---|
| [639] | 103 | /* | 
|---|
|  | 104 | * Variables | 
|---|
|  | 105 | */ | 
|---|
|  | 106 | void    (* _System PVar1Void)(int a, int b, int c, int d); | 
|---|
|  | 107 | void *  (* _System PVar1PVoid)(int a, int b, int c, int d); | 
|---|
|  | 108 | int     (* _System PVar1Int)(int a, int b, int c, int d); | 
|---|
|  | 109 | PTYPE   (* _System PVar1PType)(int a, int b, int c, int d); | 
|---|
|  | 110 |  | 
|---|
|  | 111 | /* Alternate writing which should have the same effect I think... */ | 
|---|
|  | 112 | void    (_System * PVar2Void)(int a, int b, int c, int d); | 
|---|
|  | 113 | void *  (_System * PVar2PVoid)(int a, int b, int c, int d); | 
|---|
|  | 114 | int     (_System * PVar2Int)(int a, int b, int c, int d); | 
|---|
|  | 115 | PTYPE   (_System * PVar2PType)(int a, int b, int c, int d); | 
|---|
|  | 116 |  | 
|---|
|  | 117 |  | 
|---|
| [906] | 118 | /* | 
|---|
|  | 119 | * Parameters. | 
|---|
|  | 120 | */ | 
|---|
|  | 121 | int 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); | 
|---|
| [639] | 136 |  | 
|---|
| [906] | 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 | } | 
|---|
| [639] | 143 |  | 
|---|
| [906] | 144 |  | 
|---|
|  | 145 |  | 
|---|
| [594] | 146 | extern "C" int DoC(void); | 
|---|
|  | 147 | int main(void) | 
|---|
|  | 148 | { | 
|---|
| [600] | 149 | static VFT vft = {Void, PVoid, Int, PType, | 
|---|
|  | 150 | Void, PVoid, Int, PType}; | 
|---|
| [594] | 151 |  | 
|---|
| [600] | 152 | static Typedef1Void       * pfnTypedef1Void   = Void; | 
|---|
|  | 153 | static Typedef1PVoid      * pfnTypedef1PVoid  = PVoid; | 
|---|
|  | 154 | static Typedef1Int        * pfnTypedef1Int    = Int; | 
|---|
|  | 155 | static Typedef1PType      * pfnTypedef1PType  = PType; | 
|---|
| [594] | 156 |  | 
|---|
| [600] | 157 | static Typedef2Void       * pfnTypedef2Void   = Void; | 
|---|
|  | 158 | static Typedef2PVoid      * pfnTypedef2PVoid  = PVoid; | 
|---|
|  | 159 | static Typedef2Int        * pfnTypedef2Int    = Int; | 
|---|
|  | 160 | static Typedef2PType      * pfnTypedef2PType  = PType; | 
|---|
| [594] | 161 |  | 
|---|
| [600] | 162 | static PTypedef1Void        pfnPTypedef1Void  = Void; | 
|---|
|  | 163 | static PTypedef1PVoid       pfnPTypedef1PVoid = PVoid; | 
|---|
|  | 164 | static PTypedef1Int         pfnPTypedef1Int   = Int; | 
|---|
|  | 165 | static PTypedef1PType       pfnPTypedef1PType = PType; | 
|---|
| [599] | 166 |  | 
|---|
| [600] | 167 | static PTypedef2Void        pfnPTypedef2Void  = Void; | 
|---|
|  | 168 | static PTypedef2PVoid       pfnPTypedef2PVoid = PVoid; | 
|---|
|  | 169 | static PTypedef2Int         pfnPTypedef2Int   = Int; | 
|---|
|  | 170 | static PTypedef2PType       pfnPTypedef2PType = PType; | 
|---|
| [599] | 171 |  | 
|---|
| [639] | 172 | PVar1Void   = Void; | 
|---|
|  | 173 | PVar1PVoid  = PVoid; | 
|---|
|  | 174 | PVar1Int    = Int; | 
|---|
|  | 175 | PVar1PType  = PType; | 
|---|
|  | 176 |  | 
|---|
|  | 177 | PVar2Void   = Void; | 
|---|
|  | 178 | PVar2PVoid  = PVoid; | 
|---|
|  | 179 | PVar2Int    = Int; | 
|---|
|  | 180 | PVar2PType  = PType; | 
|---|
|  | 181 |  | 
|---|
|  | 182 |  | 
|---|
| [599] | 183 | /* extern functions */ | 
|---|
|  | 184 | ExternCVoid(1,2,3,4); | 
|---|
|  | 185 | ExternCPVoid(1,2,3,4); | 
|---|
|  | 186 | ExternCInt(1,2,3,4); | 
|---|
|  | 187 | ExternCPType(1,2,3,4); | 
|---|
|  | 188 |  | 
|---|
|  | 189 | Void(1,2,3,4); | 
|---|
|  | 190 | PVoid(1,2,3,4); | 
|---|
|  | 191 | Int(1,2,3,4); | 
|---|
|  | 192 | PType(1,2,3,4); | 
|---|
|  | 193 |  | 
|---|
|  | 194 | /* class */ | 
|---|
|  | 195 | foo::StaticMemberVoid(1,2,3,4); | 
|---|
|  | 196 | foo::StaticMemberPVoid(1,2,3,4); | 
|---|
|  | 197 | foo::StaticMemberInt(1,2,3,4); | 
|---|
|  | 198 | foo::StaticMemberPType(1,2,3,4); | 
|---|
|  | 199 |  | 
|---|
| [594] | 200 | foo obj; | 
|---|
| [599] | 201 | obj.MemberVoid(1,2,3,4); | 
|---|
|  | 202 | obj.MemberPVoid(1,2,3,4); | 
|---|
|  | 203 | obj.MemberInt(1,2,3,4); | 
|---|
|  | 204 | obj.MemberPType(1,2,3,4); | 
|---|
| [594] | 205 |  | 
|---|
| [599] | 206 | /* typedefs */ | 
|---|
|  | 207 | pfnTypedef1Void(1,2,3,4); | 
|---|
|  | 208 | pfnTypedef1PVoid(1,2,3,4); | 
|---|
|  | 209 | pfnTypedef1Int(1,2,3,4); | 
|---|
|  | 210 | pfnTypedef1PType(1,2,3,4); | 
|---|
| [594] | 211 |  | 
|---|
| [599] | 212 | pfnTypedef2Void(1,2,3,4); | 
|---|
|  | 213 | pfnTypedef2PVoid(1,2,3,4); | 
|---|
|  | 214 | pfnTypedef2Int(1,2,3,4); | 
|---|
|  | 215 | pfnTypedef2PType(1,2,3,4); | 
|---|
|  | 216 |  | 
|---|
|  | 217 | pfnPTypedef1Void(1,2,3,4); | 
|---|
|  | 218 | pfnPTypedef1PVoid(1,2,3,4); | 
|---|
|  | 219 | pfnPTypedef1Int(1,2,3,4); | 
|---|
|  | 220 | pfnPTypedef1PType(1,2,3,4); | 
|---|
|  | 221 |  | 
|---|
|  | 222 | pfnPTypedef2Void(1,2,3,4); | 
|---|
|  | 223 | pfnPTypedef2PVoid(1,2,3,4); | 
|---|
|  | 224 | pfnPTypedef2Int(1,2,3,4); | 
|---|
|  | 225 | pfnPTypedef2PType(1,2,3,4); | 
|---|
|  | 226 |  | 
|---|
|  | 227 |  | 
|---|
|  | 228 | /* structs */ | 
|---|
|  | 229 | vft.PStructMemberVoid(1,2,3,4); | 
|---|
|  | 230 | vft.PStructMemberPVoid(1,2,3,4); | 
|---|
|  | 231 | vft.PStructMemberInt(1,2,3,4); | 
|---|
|  | 232 | vft.PStructMemberPType(1,2,3,4); | 
|---|
|  | 233 |  | 
|---|
|  | 234 | vft.PStructMember2Void(1,2,3,4); | 
|---|
|  | 235 | vft.PStructMember2PVoid(1,2,3,4); | 
|---|
|  | 236 | vft.PStructMember2Int(1,2,3,4); | 
|---|
|  | 237 | vft.PStructMember2PType(1,2,3,4); | 
|---|
|  | 238 |  | 
|---|
| [639] | 239 | /* variables */ | 
|---|
|  | 240 | PVar1Void(1,2,3,4); | 
|---|
|  | 241 | PVar1PVoid(1,2,3,4); | 
|---|
|  | 242 | PVar1Int(1,2,3,4); | 
|---|
|  | 243 | PVar1PType(1,2,3,4); | 
|---|
|  | 244 |  | 
|---|
|  | 245 | PVar2Void(1,2,3,4); | 
|---|
|  | 246 | PVar2PVoid(1,2,3,4); | 
|---|
|  | 247 | PVar2Int(1,2,3,4); | 
|---|
|  | 248 | PVar2PType(1,2,3,4); | 
|---|
|  | 249 |  | 
|---|
| [906] | 250 | /* parameters */ | 
|---|
|  | 251 | ParamArgs(Void, PVoid, Int, PType, | 
|---|
|  | 252 | Void, PVoid, Int, PType); | 
|---|
|  | 253 |  | 
|---|
|  | 254 |  | 
|---|
| [595] | 255 | /* test C stuff */ | 
|---|
| [594] | 256 | DoC(); | 
|---|
|  | 257 |  | 
|---|
| [600] | 258 | printf("Successfully executed _System testcase (assumed).\n"); | 
|---|
| [594] | 259 | return 0; | 
|---|
|  | 260 | } | 
|---|
|  | 261 |  | 
|---|