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