brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · f775a32 Raw
66 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s2 3typedef struct CGColor * __attribute__ ((NSObject)) CGColorRef;4typedef struct CGColor * __attribute__((NSObject(12))) Illegal;  // expected-error {{'NSObject' attribute takes no arguments}}5 6static int count;7static CGColorRef tmp = 0;8 9typedef struct S1  __attribute__ ((NSObject)) CGColorRef1; // expected-error {{'NSObject' attribute is for pointer types only}}10typedef void *  __attribute__ ((NSObject)) CGColorRef2; // no-warning11typedef void * CFTypeRef;12 13@interface HandTested {14@public15    CGColorRef x;16}17 18@property(copy) CGColorRef x;19typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; // no-warning20@property (nonatomic, retain) CGColorRefNoNSObject color;21@property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning22@property (strong, nullable) CGColorRefNoNSObject color2; // no-warning23@end24 25void setProperty(id self, id value)  {26  ((HandTested *)self)->x = value;27}28 29id getProperty(id self) {30     return (id)((HandTested *)self)->x;31}32 33@implementation HandTested34@synthesize x=x;35@synthesize myObj;36@dynamic color;37@end38 39int main(int argc, char *argv[]) {40    HandTested *to;41    to.x = tmp;  // setter42    if (tmp != to.x)43      to.x = tmp;44    return 0;45}46 47@interface I48{49   __attribute__((NSObject)) void * color; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}}50}51@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning52@end53void test_10453342(void) {54    char* __attribute__((NSObject)) string2 = 0; // expected-warning {{'NSObject' attribute may be put on a typedef only; attribute is ignored}}55}56 57@interface A { int i; }58@property(retain) __attribute__((NSObject)) int i; // expected-error {{'NSObject' attribute is for pointer types only}} \59  						   // expected-error {{property with 'retain (or strong)' attribute must be of object type}}60@end61 62@implementation A63@synthesize i;64@end65 66