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