typedef const struct __CFDictionary * CFDictionaryRef;
int GlobalAssigns;
int IvarAssigns;
int StrongCastAssigns;
@class NSObject;
@class NSString;
typedef struct {
id element;
id elementArray[10];
__strong CFDictionaryRef cfElement;
__strong CFDictionaryRef cfElementArray[10];
} struct_with_ids_t;
@interface Foo {
@public
__strong CFDictionaryRef dict;
__strong CFDictionaryRef dictArray[3];
id ivar;
id array[10];
NSObject *nsobject;
NSString *stringArray[10];
struct_with_ids_t inner;
}
@end
id GlobalId;
id GlobalArray[20];
NSObject *GlobalObject;
NSObject *GlobalObjectArray[20];
__strong CFDictionaryRef Gdict;
__strong CFDictionaryRef Gdictarray[10];
struct_with_ids_t GlobalStruct;
struct_with_ids_t GlobalStructArray[10];
void* rhs = 0;
#define ASSIGNTEST(expr, global) expr = (typeof(expr))rhs
int testGlobals(void) {
int counter = 0;
static id staticGlobalId;
static id staticGlobalArray[20];
static NSObject *staticGlobalObject;
static NSObject *staticGlobalObjectArray[20];
static __strong CFDictionaryRef staticGdict;
static __strong CFDictionaryRef staticGdictarray[10];
static struct_with_ids_t staticGlobalStruct;
static struct_with_ids_t staticGlobalStructArray[10];
ASSIGNTEST(GlobalId, GlobalAssigns); ASSIGNTEST(GlobalArray[0], GlobalAssigns); ASSIGNTEST(GlobalObject, GlobalAssigns); ASSIGNTEST(GlobalObjectArray[0], GlobalAssigns); ASSIGNTEST(Gdict, GlobalAssigns); ASSIGNTEST(Gdictarray[1], GlobalAssigns);
ASSIGNTEST(GlobalStruct.element, GlobalAssigns); ASSIGNTEST(GlobalStruct.elementArray[0], GlobalAssigns); ASSIGNTEST(GlobalStruct.cfElement, GlobalAssigns); ASSIGNTEST(GlobalStruct.cfElementArray[0], GlobalAssigns);
ASSIGNTEST(staticGlobalId, GlobalAssigns); ASSIGNTEST(staticGlobalArray[0], GlobalAssigns); ASSIGNTEST(staticGlobalObject, GlobalAssigns); ASSIGNTEST(staticGlobalObjectArray[0], GlobalAssigns); ASSIGNTEST(staticGdict, GlobalAssigns); ASSIGNTEST(staticGdictarray[1], GlobalAssigns);
ASSIGNTEST(staticGlobalStruct.element, GlobalAssigns); ASSIGNTEST(staticGlobalStruct.elementArray[0], GlobalAssigns); ASSIGNTEST(staticGlobalStruct.cfElement, GlobalAssigns); ASSIGNTEST(staticGlobalStruct.cfElementArray[0], GlobalAssigns);
return counter;
}
int testIvars(void) {
Foo *foo;
int counter = 0;
ASSIGNTEST(foo->ivar, IvarAssigns); ASSIGNTEST(foo->dict, IvarAssigns); ASSIGNTEST(foo->dictArray[0], IvarAssigns); ASSIGNTEST(foo->array[0], IvarAssigns); ASSIGNTEST(foo->nsobject, IvarAssigns); ASSIGNTEST(foo->stringArray[0], IvarAssigns); ASSIGNTEST(foo->inner.element, IvarAssigns); ASSIGNTEST(foo->inner.elementArray[0], IvarAssigns); ASSIGNTEST(foo->inner.cfElement, IvarAssigns); ASSIGNTEST(foo->inner.cfElementArray[0], IvarAssigns);
return counter;
}