1f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc@interface Test { 4f4a2713aSLionel Sambuc int x; 5f4a2713aSLionel Sambuc} 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuc-(void) setX: (int) d; 8f4a2713aSLionel Sambuc@end 9f4a2713aSLionel Sambuc 10f4a2713aSLionel Sambucextern struct foo x; 11f4a2713aSLionel Sambuc 12f4a2713aSLionel Sambuc@implementation Test 13f4a2713aSLionel Sambuc 14f4a2713aSLionel Sambuc-(void) setX: (int) n { 15f4a2713aSLionel Sambuc x = n; 16f4a2713aSLionel Sambuc} 17f4a2713aSLionel Sambuc 18f4a2713aSLionel Sambuc@end 19f4a2713aSLionel Sambuc 20f4a2713aSLionel Sambuc@interface Ivar 21f4a2713aSLionel Sambuc- (float*)method; 22f4a2713aSLionel Sambuc@end 23f4a2713aSLionel Sambuc 24f4a2713aSLionel Sambuc@interface A { 25f4a2713aSLionel Sambuc A *Ivar; 26f4a2713aSLionel Sambuc} 27f4a2713aSLionel Sambuc- (int*)method; 28f4a2713aSLionel Sambuc@end 29f4a2713aSLionel Sambuc 30f4a2713aSLionel Sambuc@implementation A 31f4a2713aSLionel Sambuc- (int*)method { 32f4a2713aSLionel Sambuc int *ip = [Ivar method]; // expected-warning{{incompatible pointer types initializing 'int *' with an expression of type 'float *'}} 33f4a2713aSLionel Sambuc // Note that there is no warning in Objective-C++ 34f4a2713aSLionel Sambuc return 0; 35f4a2713aSLionel Sambuc} 36f4a2713aSLionel Sambuc@end 37f4a2713aSLionel Sambuc 38f4a2713aSLionel Sambuc@interface TwoIvars { 39f4a2713aSLionel Sambuc int a; 40f4a2713aSLionel Sambuc int b; 41f4a2713aSLionel Sambuc} 42f4a2713aSLionel Sambuc@end 43f4a2713aSLionel Sambuc 44f4a2713aSLionel Sambuc@implementation TwoIvars 45f4a2713aSLionel Sambuc+ (int)classMethod { 46f4a2713aSLionel Sambuc return a + b; // expected-error{{instance variable 'a' accessed in class method}} \ 47f4a2713aSLionel Sambuc // expected-error{{instance variable 'b' accessed in class method}} 48f4a2713aSLionel Sambuc} 49f4a2713aSLionel Sambuc@end 50f4a2713aSLionel Sambuc 51f4a2713aSLionel Sambuc// rdar://10309454 52f4a2713aSLionel Sambuc@interface Radar10309454 53f4a2713aSLionel Sambuc{ 54f4a2713aSLionel Sambuc int IVAR; // expected-note 4 {{previous definition is here}} 55f4a2713aSLionel Sambuc} 56f4a2713aSLionel Sambuc@end 57f4a2713aSLionel Sambuc 58f4a2713aSLionel Sambuc@interface Radar10309454() 59f4a2713aSLionel Sambuc{ 60f4a2713aSLionel Sambuc int IVAR; // expected-error {{instance variable is already declared}} 61f4a2713aSLionel Sambuc int PIVAR; // expected-note {{previous definition is here}} 62f4a2713aSLionel Sambuc} 63f4a2713aSLionel Sambuc@end 64f4a2713aSLionel Sambuc 65f4a2713aSLionel Sambuc@interface Radar10309454() 66f4a2713aSLionel Sambuc{ 67f4a2713aSLionel Sambuc int IVAR; // expected-error {{instance variable is already declared}} 68f4a2713aSLionel Sambuc} 69f4a2713aSLionel Sambuc@end 70f4a2713aSLionel Sambuc 71f4a2713aSLionel Sambuc@interface Radar10309454() 72f4a2713aSLionel Sambuc{ 73f4a2713aSLionel Sambuc int IVAR; // expected-error {{instance variable is already declared}} 74f4a2713aSLionel Sambuc int PIVAR; // expected-error {{instance variable is already declared}} 75f4a2713aSLionel Sambuc} 76f4a2713aSLionel Sambuc@end 77f4a2713aSLionel Sambuc 78f4a2713aSLionel Sambuc@implementation Radar10309454 79f4a2713aSLionel Sambuc{ 80f4a2713aSLionel Sambuc int IVAR; // expected-error {{instance variable is already declared}} 81f4a2713aSLionel Sambuc} 82f4a2713aSLionel Sambuc@end 83f4a2713aSLionel Sambuc 84f4a2713aSLionel Sambuc// PR5984 85f4a2713aSLionel Sambuc// rdar://14037151 86f4a2713aSLionel Sambuc@interface Radar14037151 { 87f4a2713aSLionel Sambuc int myStatus; 88f4a2713aSLionel Sambuc} 89f4a2713aSLionel Sambuc- (int) test; 90f4a2713aSLionel Sambuc@end 91f4a2713aSLionel Sambuc 92f4a2713aSLionel Sambuc@implementation Radar14037151 93f4a2713aSLionel Sambuc- (int) test 94f4a2713aSLionel Sambuc{ 95f4a2713aSLionel Sambuc myStatus = 1; // works 96f4a2713aSLionel Sambuc __typeof(myStatus) __in; // works. 97f4a2713aSLionel Sambuc union U { 98f4a2713aSLionel Sambuc __typeof(myStatus) __in; // fails. 99f4a2713aSLionel Sambuc }; 100f4a2713aSLionel Sambuc struct S { 101f4a2713aSLionel Sambuc __typeof(myStatus) __in; // fails. 102*0a6a1f1dSLionel Sambuc struct S1 { // expected-warning {{declaration does not declare anything}} 103f4a2713aSLionel Sambuc __typeof(myStatus) __in; // fails. 104*0a6a1f1dSLionel Sambuc struct S { // expected-warning {{declaration does not declare anything}} 105f4a2713aSLionel Sambuc __typeof(myStatus) __in; // fails. 106f4a2713aSLionel Sambuc }; 107f4a2713aSLionel Sambuc }; 108f4a2713aSLionel Sambuc }; 109f4a2713aSLionel Sambuc 110f4a2713aSLionel Sambuc return 0; 111f4a2713aSLionel Sambuc} 112f4a2713aSLionel Sambuc@end 113f4a2713aSLionel Sambuc 114f4a2713aSLionel Sambuc// rdar://14278560 115f4a2713aSLionel Sambuc@class NSString, NSData, NSNumber; 116f4a2713aSLionel Sambuc 117f4a2713aSLionel Sambuc@interface NSObject 118f4a2713aSLionel Sambuc{ 119f4a2713aSLionel Sambuc Class isa; 120f4a2713aSLionel Sambuc} 121f4a2713aSLionel Sambuc@end 122f4a2713aSLionel Sambuc 123f4a2713aSLionel Sambuc@interface Foo 124f4a2713aSLionel Sambuc{ 125f4a2713aSLionel Sambuc int a; 126f4a2713aSLionel Sambuc NSString* b; 127f4a2713aSLionel Sambuc NSData* c; 128f4a2713aSLionel Sambuc} 129f4a2713aSLionel Sambuc@end 130f4a2713aSLionel Sambuc 131f4a2713aSLionel Sambuc@interface Bar : Foo 132f4a2713aSLionel Sambuc@end 133f4a2713aSLionel Sambuc 134f4a2713aSLionel Sambuc@interface Bar () { 135f4a2713aSLionel Sambuc NSString *q_strong; 136f4a2713aSLionel Sambuc NSNumber *r_strong; 137f4a2713aSLionel Sambuc int d; // expected-note {{previous definition is here}} 138f4a2713aSLionel Sambuc NSString *e_strong; // expected-note {{previous definition is here}} 139f4a2713aSLionel Sambuc NSData *f_weak; // expected-note {{previous definition is here}} 140f4a2713aSLionel Sambuc int g; // expected-note 2 {{previous definition is here}} 141f4a2713aSLionel Sambuc} 142f4a2713aSLionel Sambuc@end 143f4a2713aSLionel Sambuc 144f4a2713aSLionel Sambuc@interface Bar () { 145f4a2713aSLionel Sambuc int g; // expected-note {{previous definition is here}} \ 146f4a2713aSLionel Sambuc // expected-error {{instance variable is already declared}} 147f4a2713aSLionel Sambuc} 148f4a2713aSLionel Sambuc@end 149f4a2713aSLionel Sambuc 150f4a2713aSLionel Sambuc@implementation Bar { 151f4a2713aSLionel Sambuc int d; // expected-error {{instance variable is already declared}} 152f4a2713aSLionel Sambuc NSString *e_strong; // expected-error {{instance variable is already declared}} 153f4a2713aSLionel Sambuc NSData *f_weak; // expected-error {{instance variable is already declared}} 154f4a2713aSLionel Sambuc NSData *g; // expected-error 2 {{instance variable is already declared}} 155f4a2713aSLionel Sambuc} 156f4a2713aSLionel Sambuc@end 157