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; // expected-note{{also found}} 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 @interface Sub2 : Super 117 - (int)method2; 118 @end 119 120 @implementation Sub2 121 - (int)method2 { 122 return [supper method2]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}} 123 } 124 @end 125 126 @interface Ivar 127 @end 128 129 @protocol Proto 130 @property (retain) id ivar; 131 @end 132 133 #ifdef NON_FIXITS 134 @interface User <Proto> 135 - (void)method; // expected-note{{also found}} 136 @end 137 138 @implementation User 139 @synthesize ivar; 140 141 - (void)method { 142 // Test that we don't correct 'ivar' to 'Ivar' e 143 [ivar method]; // expected-warning{{multiple methods named 'method' found}} 144 } 145 @end 146 #endif 147 148 void f(A *a) { 149 f(a) // expected-error{{expected ';' after expression}} 150 [a methodA] // expected-error{{expected ';' after expression}} 151 [A methodA] // expected-error{{expected ';' after expression}} 152 } 153 154 #ifdef NON_FIXITS 155 @interface Sub3 : Super 156 - (int)method3; 157 @end 158 159 @implementation Sub3 160 - (int)method3 { 161 int x = super; // expected-error{{use of undeclared identifier 'super'}} 162 return 0; 163 } 164 @end 165 #endif 166