| 1 |
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify -Wno-objc-root-class %s |
| 2 |
|
| 3 |
@interface I |
| 4 |
{ |
| 5 |
int IVAR; // expected-note{{instance variable is declared here}} |
| 6 |
int name; |
| 7 |
} |
| 8 |
@property int d1; |
| 9 |
@property id prop_id; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for object}} |
| 10 |
@property int name; |
| 11 |
@end |
| 12 |
|
| 13 |
@interface I(CAT) |
| 14 |
@property int d1; |
| 15 |
@end |
| 16 |
|
| 17 |
@implementation I |
| 18 |
@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}} |
| 19 |
@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}} |
| 20 |
@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} // expected-note {{previous declaration is here}} |
| 21 |
@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' ('id') does not match type of instance variable 'IVAR' ('int')}} // expected-error {{property 'prop_id' is already implemented}} |
| 22 |
@synthesize name; // OK! property with same name as an accessible ivar of same name |
| 23 |
@end |
| 24 |
|
| 25 |
@implementation I(CAT) |
| 26 |
@synthesize d1; // expected-error {{@synthesize not allowed in a category's implementation}} |
| 27 |
@dynamic bad; // expected-error {{property implementation must have its declaration in the category 'CAT'}} |
| 28 |
@end |
| 29 |
|
| 30 |
@implementation E // expected-warning {{cannot find interface declaration for 'E'}} |
| 31 |
@dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}} |
| 32 |
@end |
| 33 |
|
| 34 |
@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}} |
| 35 |
@dynamic d; // expected-error {{property implementation in a category with no category declaration}} |
| 36 |
@end |
| 37 |
|
| 38 |
@interface Foo |
| 39 |
@property double bar; |
| 40 |
@end |
| 41 |
|
| 42 |
int func1(void) { |
| 43 |
id foo; |
| 44 |
double bar = [foo bar]; |
| 45 |
return 0; |
| 46 |
} |
| 47 |
|
| 48 |
// PR3932 |
| 49 |
typedef id BYObjectIdentifier; |
| 50 |
@interface Foo1 { |
| 51 |
void *isa; |
| 52 |
} |
| 53 |
@property(copy) BYObjectIdentifier identifier; |
| 54 |
@end |
| 55 |
|
| 56 |
@interface Foo2 |
| 57 |
{ |
| 58 |
int ivar; |
| 59 |
} |
| 60 |
@property int treeController; // expected-note {{property declared here}} |
| 61 |
@property int ivar; // OK |
| 62 |
@property int treeController; // expected-error {{property has a previous declaration}} |
| 63 |
@end |
| 64 |
|
| 65 |
@synthesize window; // expected-error {{missing context for property implementation declaration}} |
| 66 |
|
| 67 |
Class test6_getClass(void); |
| 68 |
@interface Test6 |
| 69 |
@end |
| 70 |
@implementation Test6 |
| 71 |
+ (float) globalValue { return 5.0f; } |
| 72 |
+ (float) gv { return test6_getClass().globalValue; } |
| 73 |
@end |
| 74 |
|
| 75 |
@interface Test7 |
| 76 |
@property unsigned length; |
| 77 |
@end |
| 78 |
void test7(Test7 *t) { |
| 79 |
char data[t.length] = {}; |
| 80 |
} |