1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify -Wno-objc-root-class %s 2*f4a2713aSLionel Sambuc// RUN: cp %s %t 3*f4a2713aSLionel Sambuc// RUN: not %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fixit -Wno-objc-root-class %t 4*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -pedantic -Werror -Wno-objc-root-class %t 5*f4a2713aSLionel Sambuc// RUN: grep "@implementation Sub3" %t 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc@interface NSString // expected-note 2{{'NSString' declared here}} 8*f4a2713aSLionel Sambuc+ (int)method:(int)x; 9*f4a2713aSLionel Sambuc@end 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambucvoid test() { 12*f4a2713aSLionel Sambuc NSstring *str = @"A string"; // expected-error{{unknown type name 'NSstring'; did you mean 'NSString'?}} 13*f4a2713aSLionel Sambuc} 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc@protocol P1 16*f4a2713aSLionel Sambuc@optional 17*f4a2713aSLionel Sambuc@property int *sprop; // expected-note{{'sprop' declared here}} 18*f4a2713aSLionel Sambuc@end 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc@interface A 21*f4a2713aSLionel Sambuc{ 22*f4a2713aSLionel Sambuc int his_ivar; // expected-note 2{{'his_ivar' declared here}} 23*f4a2713aSLionel Sambuc float wibble; 24*f4a2713aSLionel Sambuc} 25*f4a2713aSLionel Sambuc- (void)methodA; 26*f4a2713aSLionel Sambuc+ (void)methodA; 27*f4a2713aSLionel Sambuc@property int his_prop; // expected-note{{'his_prop' declared here}} 28*f4a2713aSLionel Sambuc@end 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc@interface B : A <P1> 31*f4a2713aSLionel Sambuc{ 32*f4a2713aSLionel Sambuc int her_ivar; // expected-note 2{{'her_ivar' declared here}} 33*f4a2713aSLionel Sambuc} 34*f4a2713aSLionel Sambuc 35*f4a2713aSLionel Sambuc@property int her_prop; // expected-note{{'her_prop' declared here}} 36*f4a2713aSLionel Sambuc- (void)inst_method1:(int)a; 37*f4a2713aSLionel Sambuc+ (void)class_method1; 38*f4a2713aSLionel Sambuc@end 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc@implementation A 41*f4a2713aSLionel Sambuc@synthesize his_prop = his_ivar; 42*f4a2713aSLionel Sambuc- (void)methodA { } 43*f4a2713aSLionel Sambuc+ (void)methodA { } 44*f4a2713aSLionel Sambuc@end 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc@implementation B 47*f4a2713aSLionel Sambuc@synthesize her_prop = her_ivar; 48*f4a2713aSLionel Sambuc 49*f4a2713aSLionel Sambuc-(void)inst_method1:(int)a { 50*f4a2713aSLionel Sambuc herivar = a; // expected-error{{use of undeclared identifier 'herivar'; did you mean 'her_ivar'?}} 51*f4a2713aSLionel Sambuc hisivar = a; // expected-error{{use of undeclared identifier 'hisivar'; did you mean 'his_ivar'?}} 52*f4a2713aSLionel Sambuc self->herivar = a; // expected-error{{'B' does not have a member named 'herivar'; did you mean 'her_ivar'?}} 53*f4a2713aSLionel Sambuc self->hisivar = a; // expected-error{{'B' does not have a member named 'hisivar'; did you mean 'his_ivar'?}} 54*f4a2713aSLionel Sambuc self.hisprop = 0; // expected-error{{property 'hisprop' not found on object of type 'B *'; did you mean 'his_prop'?}} 55*f4a2713aSLionel Sambuc self.herprop = 0; // expected-error{{property 'herprop' not found on object of type 'B *'; did you mean 'her_prop'?}} 56*f4a2713aSLionel Sambuc self.s_prop = 0; // expected-error{{property 's_prop' not found on object of type 'B *'; did you mean 'sprop'?}} 57*f4a2713aSLionel Sambuc} 58*f4a2713aSLionel Sambuc 59*f4a2713aSLionel Sambuc+(void)class_method1 { 60*f4a2713aSLionel Sambuc} 61*f4a2713aSLionel Sambuc@end 62*f4a2713aSLionel Sambuc 63*f4a2713aSLionel Sambucvoid test_message_send(B* b) { 64*f4a2713aSLionel Sambuc [NSstring method:17]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}} 65*f4a2713aSLionel Sambuc} 66*f4a2713aSLionel Sambuc 67*f4a2713aSLionel Sambuc@interface Collide // expected-note{{'Collide' declared here}} 68*f4a2713aSLionel Sambuc{ 69*f4a2713aSLionel Sambuc@public 70*f4a2713aSLionel Sambuc int value; // expected-note{{'value' declared here}} 71*f4a2713aSLionel Sambuc} 72*f4a2713aSLionel Sambuc 73*f4a2713aSLionel Sambuc@property int value; // expected-note{{'value' declared here}} 74*f4a2713aSLionel Sambuc@end 75*f4a2713aSLionel Sambuc 76*f4a2713aSLionel Sambuc@implementation Collide 77*f4a2713aSLionel Sambuc@synthesize value = value; 78*f4a2713aSLionel Sambuc@end 79*f4a2713aSLionel Sambuc 80*f4a2713aSLionel Sambucvoid test2(Collide *a) { 81*f4a2713aSLionel Sambuc a.valu = 17; // expected-error{{property 'valu' not found on object of type 'Collide *'; did you mean 'value'?}} 82*f4a2713aSLionel Sambuc a->vale = 17; // expected-error{{'Collide' does not have a member named 'vale'; did you mean 'value'?}} 83*f4a2713aSLionel Sambuc} 84*f4a2713aSLionel Sambuc 85*f4a2713aSLionel Sambuc#ifdef NON_FIXITS 86*f4a2713aSLionel Sambuc@interface Derived : Collid // expected-error{{cannot find interface declaration for 'Collid', superclass of 'Derived'; did you mean 'Collide'?}} 87*f4a2713aSLionel Sambuc@end 88*f4a2713aSLionel Sambuc#endif 89*f4a2713aSLionel Sambuc 90*f4a2713aSLionel Sambuc#ifdef NON_FIXITS 91*f4a2713aSLionel Sambuc@protocol NetworkSocket // expected-note{{'NetworkSocket' declared here}} 92*f4a2713aSLionel Sambuc- (int)send:(void*)buffer bytes:(int)bytes; 93*f4a2713aSLionel Sambuc@end 94*f4a2713aSLionel Sambuc 95*f4a2713aSLionel Sambuc@interface IPv6 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}} 96*f4a2713aSLionel Sambuc@end 97*f4a2713aSLionel Sambuc#endif 98*f4a2713aSLionel Sambuc 99*f4a2713aSLionel Sambuc@interface Super 100*f4a2713aSLionel Sambuc- (int)method; // expected-note{{using}} 101*f4a2713aSLionel Sambuc- (int)method2; 102*f4a2713aSLionel Sambuc- (int)method3:(id)x; 103*f4a2713aSLionel Sambuc@end 104*f4a2713aSLionel Sambuc 105*f4a2713aSLionel Sambuc@interface Sub : Super 106*f4a2713aSLionel Sambuc- (int)method; 107*f4a2713aSLionel Sambuc@end 108*f4a2713aSLionel Sambuc 109*f4a2713aSLionel Sambuc@implementation Sub 110*f4a2713aSLionel Sambuc- (int)method { 111*f4a2713aSLionel Sambuc return [supper method]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}} 112*f4a2713aSLionel Sambuc} 113*f4a2713aSLionel Sambuc 114*f4a2713aSLionel Sambuc@end 115*f4a2713aSLionel Sambuc 116*f4a2713aSLionel Sambucdouble *isupper(int); 117*f4a2713aSLionel Sambuc 118*f4a2713aSLionel Sambuc@interface Sub2 : Super 119*f4a2713aSLionel Sambuc- (int)method2; 120*f4a2713aSLionel Sambuc@end 121*f4a2713aSLionel Sambuc 122*f4a2713aSLionel Sambuc@implementation Sub2 123*f4a2713aSLionel Sambuc- (int)method2 { 124*f4a2713aSLionel Sambuc return [supper method2]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}} 125*f4a2713aSLionel Sambuc} 126*f4a2713aSLionel Sambuc@end 127*f4a2713aSLionel Sambuc 128*f4a2713aSLionel Sambuc@interface Ivar 129*f4a2713aSLionel Sambuc@end 130*f4a2713aSLionel Sambuc 131*f4a2713aSLionel Sambuc@protocol Proto 132*f4a2713aSLionel Sambuc@property (retain) id ivar; 133*f4a2713aSLionel Sambuc@end 134*f4a2713aSLionel Sambuc 135*f4a2713aSLionel Sambuc#ifdef NON_FIXITS 136*f4a2713aSLionel Sambuc@interface User <Proto> 137*f4a2713aSLionel Sambuc- (void)method; // expected-note{{also found}} 138*f4a2713aSLionel Sambuc@end 139*f4a2713aSLionel Sambuc 140*f4a2713aSLionel Sambuc@implementation User 141*f4a2713aSLionel Sambuc@synthesize ivar; 142*f4a2713aSLionel Sambuc 143*f4a2713aSLionel Sambuc- (void)method { 144*f4a2713aSLionel Sambuc // Test that we don't correct 'ivar' to 'Ivar' e 145*f4a2713aSLionel Sambuc [ivar method]; // expected-warning{{multiple methods named 'method' found}} 146*f4a2713aSLionel Sambuc} 147*f4a2713aSLionel Sambuc@end 148*f4a2713aSLionel Sambuc#endif 149*f4a2713aSLionel Sambuc 150*f4a2713aSLionel Sambucvoid f(A *a) { 151*f4a2713aSLionel Sambuc f(a) // expected-error{{expected ';' after expression}} 152*f4a2713aSLionel Sambuc [a methodA] // expected-error{{expected ';' after expression}} 153*f4a2713aSLionel Sambuc [A methodA] // expected-error{{expected ';' after expression}} 154*f4a2713aSLionel Sambuc} 155*f4a2713aSLionel Sambuc 156*f4a2713aSLionel Sambuc#ifdef NON_FIXITS 157*f4a2713aSLionel Sambuc@interface Sub3 : Super 158*f4a2713aSLionel Sambuc- (int)method3; 159*f4a2713aSLionel Sambuc@end 160*f4a2713aSLionel Sambuc 161*f4a2713aSLionel Sambuc@implementation Sub3 162*f4a2713aSLionel Sambuc- (int)method3 { 163*f4a2713aSLionel Sambuc int x = super; // expected-error{{use of undeclared identifier 'super'}} 164*f4a2713aSLionel Sambuc return 0; 165*f4a2713aSLionel Sambuc} 166*f4a2713aSLionel Sambuc@end 167*f4a2713aSLionel Sambuc#endif 168