| [601] | 1 | /* $Id: 572c.c 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 | */ | 
|---|
| [600] | 14 | typedef struct some_struct_pointer * PTYPE; | 
|---|
|  | 15 |  | 
|---|
|  | 16 | /* | 
|---|
|  | 17 | * Function and method declarations. | 
|---|
|  | 18 | * Checks mangling. | 
|---|
|  | 19 | */ | 
|---|
|  | 20 | /* No underscore, No mangling. */ | 
|---|
|  | 21 | void    _Optlink            CVoid(int a, int b, int c, int d); | 
|---|
|  | 22 | void *  _Optlink            CPVoid(int a, int b, int c, int d); | 
|---|
|  | 23 | int     _Optlink            CInt(int a, int b, int c, int d); | 
|---|
|  | 24 | PTYPE   _Optlink            CPType(int a, int b, int c, int d); | 
|---|
|  | 25 |  | 
|---|
|  | 26 | /* | 
|---|
|  | 27 | * Typedefs. | 
|---|
|  | 28 | * Checks that there is not warnings on these. | 
|---|
|  | 29 | */ | 
|---|
|  | 30 | typedef void    _Optlink    Typedef1Void(int a, int b, int c, int d); | 
|---|
|  | 31 | typedef void *  _Optlink    Typedef1PVoid(int a, int b, int c, int d); | 
|---|
|  | 32 | typedef int     _Optlink    Typedef1Int(int a, int b, int c, int d); | 
|---|
|  | 33 | typedef PTYPE   _Optlink    Typedef1PType(int a, int b, int c, int d); | 
|---|
|  | 34 |  | 
|---|
|  | 35 | typedef void    (_Optlink   Typedef2Void)(int a, int b, int c, int d); | 
|---|
|  | 36 | typedef void *  (_Optlink   Typedef2PVoid)(int a, int b, int c, int d); | 
|---|
|  | 37 | typedef int     (_Optlink   Typedef2Int)(int a, int b, int c, int d); | 
|---|
|  | 38 | typedef PTYPE   (_Optlink   Typedef2PType)(int a, int b, int c, int d); | 
|---|
|  | 39 |  | 
|---|
|  | 40 | typedef void    (* _Optlink PTypedef1Void)(int a, int b, int c, int d); | 
|---|
|  | 41 | typedef void *  (* _Optlink PTypedef1PVoid)(int a, int b, int c, int d); | 
|---|
|  | 42 | typedef int     (* _Optlink PTypedef1Int)(int a, int b, int c, int d); | 
|---|
|  | 43 | typedef PTYPE   (* _Optlink PTypedef1PType)(int a, int b, int c, int d); | 
|---|
|  | 44 |  | 
|---|
|  | 45 | /* Alternate writing which should have the same effect I think... */ | 
|---|
|  | 46 | typedef void    (_Optlink * PTypedef2Void)(int a, int b, int c, int d); | 
|---|
|  | 47 | typedef void *  (_Optlink * PTypedef2PVoid)(int a, int b, int c, int d); | 
|---|
|  | 48 | typedef int     (_Optlink * PTypedef2Int)(int a, int b, int c, int d); | 
|---|
|  | 49 | typedef PTYPE   (_Optlink * PTypedef2PType)(int a, int b, int c, int d); | 
|---|
|  | 50 |  | 
|---|
|  | 51 |  | 
|---|
|  | 52 | /* | 
|---|
|  | 53 | * Structures. | 
|---|
|  | 54 | */ | 
|---|
|  | 55 | typedef struct VFT | 
|---|
|  | 56 | { | 
|---|
|  | 57 | void    (_Optlink * PStructMemberVoid)(int a, int b, int c, int d); | 
|---|
|  | 58 | void *  (_Optlink * PStructMemberPVoid)(int a, int b, int c, int d); | 
|---|
|  | 59 | int     (_Optlink * PStructMemberInt)(int a, int b, int c, int d); | 
|---|
|  | 60 | PTYPE   (_Optlink * PStructMemberPType)(int a, int b, int c, int d); | 
|---|
|  | 61 |  | 
|---|
|  | 62 | /* Alternate writing which should have the same effect I think... */ | 
|---|
|  | 63 | void    (_Optlink * PStructMember2Void)(int a, int b, int c, int d); | 
|---|
|  | 64 | void *  (_Optlink * PStructMember2PVoid)(int a, int b, int c, int d); | 
|---|
|  | 65 | int     (_Optlink * PStructMember2Int)(int a, int b, int c, int d); | 
|---|
|  | 66 | PTYPE   (_Optlink * PStructMember2PType)(int a, int b, int c, int d); | 
|---|
|  | 67 |  | 
|---|
|  | 68 | } VFT, *PVFT; | 
|---|
|  | 69 |  | 
|---|
|  | 70 |  | 
|---|
| [639] | 71 | /* | 
|---|
|  | 72 | * Variables | 
|---|
|  | 73 | */ | 
|---|
|  | 74 | void    (* _Optlink PVar1Void)(int a, int b, int c, int d); | 
|---|
|  | 75 | void *  (* _Optlink PVar1PVoid)(int a, int b, int c, int d); | 
|---|
|  | 76 | int     (* _Optlink PVar1Int)(int a, int b, int c, int d); | 
|---|
|  | 77 | PTYPE   (* _Optlink PVar1PType)(int a, int b, int c, int d); | 
|---|
|  | 78 |  | 
|---|
|  | 79 | /* Alternate writing which should have the same effect I think... */ | 
|---|
|  | 80 | void    (_Optlink * PVar2Void)(int a, int b, int c, int d); | 
|---|
|  | 81 | void *  (_Optlink * PVar2PVoid)(int a, int b, int c, int d); | 
|---|
|  | 82 | int     (_Optlink * PVar2Int)(int a, int b, int c, int d); | 
|---|
|  | 83 | PTYPE   (_Optlink * PVar2PType)(int a, int b, int c, int d); | 
|---|
|  | 84 |  | 
|---|
|  | 85 |  | 
|---|
| [600] | 86 | int DoC(int a, int b, int c, int d) | 
|---|
|  | 87 | { | 
|---|
|  | 88 | static VFT vft = {CVoid, CPVoid, CInt, CPType, | 
|---|
|  | 89 | CVoid, CPVoid, CInt, CPType}; | 
|---|
|  | 90 |  | 
|---|
|  | 91 | static Typedef1Void       * pfnTypedef1Void   = CVoid; | 
|---|
|  | 92 | static Typedef1PVoid      * pfnTypedef1PVoid  = CPVoid; | 
|---|
|  | 93 | static Typedef1Int        * pfnTypedef1Int    = CInt; | 
|---|
|  | 94 | static Typedef1PType      * pfnTypedef1PType  = CPType; | 
|---|
|  | 95 |  | 
|---|
|  | 96 | static Typedef2Void       * pfnTypedef2Void   = CVoid; | 
|---|
|  | 97 | static Typedef2PVoid      * pfnTypedef2PVoid  = CPVoid; | 
|---|
|  | 98 | static Typedef2Int        * pfnTypedef2Int    = CInt; | 
|---|
|  | 99 | static Typedef2PType      * pfnTypedef2PType  = CPType; | 
|---|
|  | 100 |  | 
|---|
|  | 101 | static PTypedef1Void        pfnPTypedef1Void  = CVoid; | 
|---|
|  | 102 | static PTypedef1PVoid       pfnPTypedef1PVoid = CPVoid; | 
|---|
|  | 103 | static PTypedef1Int         pfnPTypedef1Int   = CInt; | 
|---|
|  | 104 | static PTypedef1PType       pfnPTypedef1PType = CPType; | 
|---|
|  | 105 |  | 
|---|
|  | 106 | static PTypedef2Void        pfnPTypedef2Void  = CVoid; | 
|---|
|  | 107 | static PTypedef2PVoid       pfnPTypedef2PVoid = CPVoid; | 
|---|
|  | 108 | static PTypedef2Int         pfnPTypedef2Int   = CInt; | 
|---|
|  | 109 | static PTypedef2PType       pfnPTypedef2PType = CPType; | 
|---|
|  | 110 |  | 
|---|
| [639] | 111 | PVar1Void   = CVoid; | 
|---|
|  | 112 | PVar1PVoid  = CPVoid; | 
|---|
|  | 113 | PVar1Int    = CInt; | 
|---|
|  | 114 | PVar1PType  = CPType; | 
|---|
| [600] | 115 |  | 
|---|
| [639] | 116 | PVar2Void   = CVoid; | 
|---|
|  | 117 | PVar2PVoid  = CPVoid; | 
|---|
|  | 118 | PVar2Int    = CInt; | 
|---|
|  | 119 | PVar2PType  = CPType; | 
|---|
|  | 120 |  | 
|---|
|  | 121 |  | 
|---|
| [600] | 122 | /* extern functions */ | 
|---|
|  | 123 | CVoid(1,2,3,4); | 
|---|
|  | 124 | CPVoid(1,2,3,4); | 
|---|
|  | 125 | CInt(1,2,3,4); | 
|---|
|  | 126 | CPType(1,2,3,4); | 
|---|
|  | 127 |  | 
|---|
|  | 128 | /* typedefs */ | 
|---|
|  | 129 | pfnTypedef1Void(1,2,3,4); | 
|---|
|  | 130 | pfnTypedef1PVoid(1,2,3,4); | 
|---|
|  | 131 | pfnTypedef1Int(1,2,3,4); | 
|---|
|  | 132 | pfnTypedef1PType(1,2,3,4); | 
|---|
|  | 133 |  | 
|---|
|  | 134 | pfnTypedef2Void(1,2,3,4); | 
|---|
|  | 135 | pfnTypedef2PVoid(1,2,3,4); | 
|---|
|  | 136 | pfnTypedef2Int(1,2,3,4); | 
|---|
|  | 137 | pfnTypedef2PType(1,2,3,4); | 
|---|
|  | 138 |  | 
|---|
|  | 139 | pfnPTypedef1Void(1,2,3,4); | 
|---|
|  | 140 | pfnPTypedef1PVoid(1,2,3,4); | 
|---|
|  | 141 | pfnPTypedef1Int(1,2,3,4); | 
|---|
|  | 142 | pfnPTypedef1PType(1,2,3,4); | 
|---|
|  | 143 |  | 
|---|
|  | 144 | pfnPTypedef2Void(1,2,3,4); | 
|---|
|  | 145 | pfnPTypedef2PVoid(1,2,3,4); | 
|---|
|  | 146 | pfnPTypedef2Int(1,2,3,4); | 
|---|
|  | 147 | pfnPTypedef2PType(1,2,3,4); | 
|---|
|  | 148 |  | 
|---|
|  | 149 |  | 
|---|
|  | 150 | /* structs */ | 
|---|
|  | 151 | vft.PStructMemberVoid(1,2,3,4); | 
|---|
|  | 152 | vft.PStructMemberPVoid(1,2,3,4); | 
|---|
|  | 153 | vft.PStructMemberInt(1,2,3,4); | 
|---|
|  | 154 | vft.PStructMemberPType(1,2,3,4); | 
|---|
|  | 155 |  | 
|---|
|  | 156 | vft.PStructMember2Void(1,2,3,4); | 
|---|
|  | 157 | vft.PStructMember2PVoid(1,2,3,4); | 
|---|
|  | 158 | vft.PStructMember2Int(1,2,3,4); | 
|---|
|  | 159 | vft.PStructMember2PType(1,2,3,4); | 
|---|
|  | 160 |  | 
|---|
| [639] | 161 | /* variables */ | 
|---|
|  | 162 | PVar1Void(1,2,3,4); | 
|---|
|  | 163 | PVar1PVoid(1,2,3,4); | 
|---|
|  | 164 | PVar1Int(1,2,3,4); | 
|---|
|  | 165 | PVar1PType(1,2,3,4); | 
|---|
|  | 166 |  | 
|---|
|  | 167 | PVar2Void(1,2,3,4); | 
|---|
|  | 168 | PVar2PVoid(1,2,3,4); | 
|---|
|  | 169 | PVar2Int(1,2,3,4); | 
|---|
|  | 170 | PVar2PType(1,2,3,4); | 
|---|
|  | 171 |  | 
|---|
| [600] | 172 | return 0; | 
|---|
|  | 173 | } | 
|---|
|  | 174 |  | 
|---|