1f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuctypedef struct CGColor * __attribute__ ((NSObject)) CGColorRef; 4f4a2713aSLionel Sambuctypedef struct CGColor * __attribute__((NSObject(12))) Illegal; // expected-error {{'NSObject' attribute takes no arguments}} 5f4a2713aSLionel Sambuc 6f4a2713aSLionel Sambucstatic int count; 7f4a2713aSLionel Sambucstatic CGColorRef tmp = 0; 8f4a2713aSLionel Sambuc 9*0a6a1f1dSLionel Sambuctypedef struct S1 __attribute__ ((NSObject)) CGColorRef1; // expected-error {{'NSObject' attribute is for pointer types only}} 10f4a2713aSLionel Sambuctypedef void * __attribute__ ((NSObject)) CGColorRef2; // no-warning 11f4a2713aSLionel Sambuctypedef void * CFTypeRef; 12f4a2713aSLionel Sambuc 13f4a2713aSLionel Sambuc@interface HandTested { 14f4a2713aSLionel Sambuc@public 15f4a2713aSLionel Sambuc CGColorRef x; 16f4a2713aSLionel Sambuc} 17f4a2713aSLionel Sambuc 18f4a2713aSLionel Sambuc@property(copy) CGColorRef x; 19f4a2713aSLionel Sambuc// rdar://problem/7809460 20f4a2713aSLionel Sambuctypedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; // no-warning 21f4a2713aSLionel Sambuc@property (nonatomic, retain) CGColorRefNoNSObject color; 22f4a2713aSLionel Sambuc// rdar://problem/12197822 23f4a2713aSLionel Sambuc@property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning 24f4a2713aSLionel Sambuc@end 25f4a2713aSLionel Sambuc 26f4a2713aSLionel Sambucvoid setProperty(id self, id value) { 27f4a2713aSLionel Sambuc ((HandTested *)self)->x = value; 28f4a2713aSLionel Sambuc} 29f4a2713aSLionel Sambuc 30f4a2713aSLionel Sambucid getProperty(id self) { 31f4a2713aSLionel Sambuc return (id)((HandTested *)self)->x; 32f4a2713aSLionel Sambuc} 33f4a2713aSLionel Sambuc 34f4a2713aSLionel Sambuc@implementation HandTested 35f4a2713aSLionel Sambuc@synthesize x=x; 36f4a2713aSLionel Sambuc@synthesize myObj; 37f4a2713aSLionel Sambuc@dynamic color; 38f4a2713aSLionel Sambuc@end 39f4a2713aSLionel Sambuc 40f4a2713aSLionel Sambucint main(int argc, char *argv[]) { 41f4a2713aSLionel Sambuc HandTested *to; 42f4a2713aSLionel Sambuc to.x = tmp; // setter 43f4a2713aSLionel Sambuc if (tmp != to.x) 44f4a2713aSLionel Sambuc to.x = tmp; 45f4a2713aSLionel Sambuc return 0; 46f4a2713aSLionel Sambuc} 47f4a2713aSLionel Sambuc 48f4a2713aSLionel Sambuc// rdar://10453342 49f4a2713aSLionel Sambuc@interface I 50f4a2713aSLionel Sambuc{ 51*0a6a1f1dSLionel Sambuc __attribute__((NSObject)) void * color; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}} 52f4a2713aSLionel Sambuc} 53f4a2713aSLionel Sambuc // <rdar://problem/10930507> 54f4a2713aSLionel Sambuc@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning 55f4a2713aSLionel Sambuc@end 56f4a2713aSLionel Sambucvoid test_10453342() { 57*0a6a1f1dSLionel Sambuc char* __attribute__((NSObject)) string2 = 0; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}} 58f4a2713aSLionel Sambuc} 59f4a2713aSLionel Sambuc 60f4a2713aSLionel Sambuc// rdar://11569860 61f4a2713aSLionel Sambuc@interface A { int i; } 62*0a6a1f1dSLionel Sambuc@property(retain) __attribute__((NSObject)) int i; // expected-error {{'NSObject' attribute is for pointer types only}} \ 63f4a2713aSLionel Sambuc // expected-error {{property with 'retain (or strong)' attribute must be of object type}} 64f4a2713aSLionel Sambuc@end 65f4a2713aSLionel Sambuc 66f4a2713aSLionel Sambuc@implementation A 67f4a2713aSLionel Sambuc@synthesize i; 68f4a2713aSLionel Sambuc@end 69f4a2713aSLionel Sambuc 70