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