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