3 @interface Normal
: TestRoot
8 @interface Forbidden
: TestRoot
10 @implementation Forbidden
13 struct minimal_unrealized_class
{
17 uintptr_t maskAndOccupied
;
18 struct minimal_class_ro
*ro
;
21 struct minimal_class_ro
{
25 extern struct minimal_unrealized_class OBJC_CLASS_$_Forbidden
;
27 #define RO_FORBIDS_ASSOCIATED_OBJECTS (1<<10)
29 static void *key
= &key
;
31 static void test(void);
35 struct minimal_unrealized_class
*localForbidden
= &OBJC_CLASS_$_Forbidden
;
36 localForbidden
->ro
->flags
|= RO_FORBIDS_ASSOCIATED_OBJECTS
;
40 static inline void ShouldSucceed(id obj
) {
41 objc_setAssociatedObject(obj
, key
, obj
, OBJC_ASSOCIATION_ASSIGN
);
42 id assoc
= objc_getAssociatedObject(obj
, key
);
43 fprintf(stderr
, "Associated object is %p\n", assoc
);
44 testassert(obj
== assoc
);
47 static inline void ShouldFail(id obj
) {
48 objc_setAssociatedObject(obj
, key
, obj
, OBJC_ASSOCIATION_ASSIGN
);
49 fail("should have crashed trying to set the associated object");