Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify -Wno-objc-root-class %s |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 2 | // RUN: cp %s %t |
Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 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 |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 5 | // RUN: grep "@implementation Sub3" %t |
Douglas Gregor | c37b736 | 2010-10-26 23:34:31 +0000 | [diff] [blame] | 6 | |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 7 | @interface NSString // expected-note 2{{'NSString' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 8 | + (int)method:(int)x; |
Douglas Gregor | d203a16 | 2010-01-01 00:15:04 +0000 | [diff] [blame] | 9 | @end |
| 10 | |
| 11 | void test() { |
Douglas Gregor | 6add6fb | 2011-04-27 04:02:56 +0000 | [diff] [blame] | 12 | NSstring *str = @"A string"; // expected-error{{unknown type name 'NSstring'; did you mean 'NSString'?}} |
Douglas Gregor | d203a16 | 2010-01-01 00:15:04 +0000 | [diff] [blame] | 13 | } |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 14 | |
| 15 | @protocol P1 |
Fariborz Jahanian | 3ac1eda | 2010-01-20 01:51:55 +0000 | [diff] [blame] | 16 | @optional |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 17 | @property int *sprop; // expected-note{{'sprop' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 18 | @end |
| 19 | |
| 20 | @interface A |
| 21 | { |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 22 | int his_ivar; // expected-note 2{{'his_ivar' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 23 | float wibble; |
| 24 | } |
Douglas Gregor | de037c2 | 2010-05-31 14:58:57 +0000 | [diff] [blame] | 25 | - (void)methodA; |
| 26 | + (void)methodA; |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 27 | @property int his_prop; // expected-note{{'his_prop' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 28 | @end |
| 29 | |
| 30 | @interface B : A <P1> |
| 31 | { |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 32 | int her_ivar; // expected-note 2{{'her_ivar' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 35 | @property int her_prop; // expected-note{{'her_prop' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 36 | - (void)inst_method1:(int)a; |
| 37 | + (void)class_method1; |
| 38 | @end |
| 39 | |
| 40 | @implementation A |
| 41 | @synthesize his_prop = his_ivar; |
Douglas Gregor | de037c2 | 2010-05-31 14:58:57 +0000 | [diff] [blame] | 42 | - (void)methodA { } |
| 43 | + (void)methodA { } |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 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) { |
Douglas Gregor | 47bd543 | 2010-04-14 02:46:37 +0000 | [diff] [blame] | 64 | [NSstring method:17]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 67 | @interface Collide // expected-note{{'Collide' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 68 | { |
| 69 | @public |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 70 | int value; // expected-note{{'value' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 73 | @property int value; // expected-note{{'value' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 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 | |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 85 | #ifdef NON_FIXITS |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 86 | @interface Derived : Collid // expected-error{{cannot find interface declaration for 'Collid', superclass of 'Derived'; did you mean 'Collide'?}} |
| 87 | @end |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 88 | #endif |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 89 | |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 90 | #ifdef NON_FIXITS |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 91 | @protocol NetworkSocket // expected-note{{'NetworkSocket' declared here}} |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 92 | - (int)send:(void*)buffer bytes:(int)bytes; |
| 93 | @end |
| 94 | |
Douglas Gregor | 6202119 | 2010-02-04 23:42:48 +0000 | [diff] [blame] | 95 | @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] | 96 | @end |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 97 | #endif |
Douglas Gregor | aaf8716 | 2010-04-14 20:04:41 +0000 | [diff] [blame] | 98 | |
| 99 | @interface Super |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 100 | - (int)method; // expected-note{{using}} |
Douglas Gregor | 91f7ac7 | 2010-05-18 16:14:23 +0000 | [diff] [blame] | 101 | - (int)method2; |
Douglas Gregor | 53e4b55 | 2010-10-26 17:18:00 +0000 | [diff] [blame] | 102 | - (int)method3:(id)x; |
Douglas Gregor | aaf8716 | 2010-04-14 20:04:41 +0000 | [diff] [blame] | 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 |
Douglas Gregor | c220a18 | 2010-04-19 18:02:19 +0000 | [diff] [blame] | 115 | |
Douglas Gregor | 91f7ac7 | 2010-05-18 16:14:23 +0000 | [diff] [blame] | 116 | double *isupper(int); |
| 117 | |
| 118 | @interface Sub2 : Super |
| 119 | - (int)method2; |
| 120 | @end |
| 121 | |
| 122 | @implementation Sub2 |
| 123 | - (int)method2 { |
Douglas Gregor | d0785ea | 2010-05-18 16:30:22 +0000 | [diff] [blame] | 124 | return [supper method2]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}} |
Douglas Gregor | 91f7ac7 | 2010-05-18 16:14:23 +0000 | [diff] [blame] | 125 | } |
| 126 | @end |
Douglas Gregor | 91f7ac7 | 2010-05-18 16:14:23 +0000 | [diff] [blame] | 127 | |
Douglas Gregor | c220a18 | 2010-04-19 18:02:19 +0000 | [diff] [blame] | 128 | @interface Ivar |
| 129 | @end |
| 130 | |
| 131 | @protocol Proto |
| 132 | @property (retain) id ivar; |
| 133 | @end |
| 134 | |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 135 | #ifdef NON_FIXITS |
Douglas Gregor | c220a18 | 2010-04-19 18:02:19 +0000 | [diff] [blame] | 136 | @interface User <Proto> |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 137 | - (void)method; // expected-note{{also found}} |
Douglas Gregor | c220a18 | 2010-04-19 18:02:19 +0000 | [diff] [blame] | 138 | @end |
| 139 | |
| 140 | @implementation User |
Douglas Gregor | a1d1c75 | 2010-05-18 16:57:36 +0000 | [diff] [blame] | 141 | @synthesize ivar; |
Douglas Gregor | c220a18 | 2010-04-19 18:02:19 +0000 | [diff] [blame] | 142 | |
| 143 | - (void)method { |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 144 | // Test that we don't correct 'ivar' to 'Ivar' e |
| 145 | [ivar method]; // expected-warning{{multiple methods named 'method' found}} |
Douglas Gregor | c220a18 | 2010-04-19 18:02:19 +0000 | [diff] [blame] | 146 | } |
| 147 | @end |
Ted Kremenek | e2aaf39 | 2010-05-17 23:03:33 +0000 | [diff] [blame] | 148 | #endif |
Douglas Gregor | c220a18 | 2010-04-19 18:02:19 +0000 | [diff] [blame] | 149 | |
Douglas Gregor | 1b730e8 | 2010-05-31 14:40:22 +0000 | [diff] [blame] | 150 | void f(A *a) { |
| 151 | f(a) // expected-error{{expected ';' after expression}} |
Douglas Gregor | de037c2 | 2010-05-31 14:58:57 +0000 | [diff] [blame] | 152 | [a methodA] // expected-error{{expected ';' after expression}} |
| 153 | [A methodA] // expected-error{{expected ';' after expression}} |
Douglas Gregor | 1b730e8 | 2010-05-31 14:40:22 +0000 | [diff] [blame] | 154 | } |
Douglas Gregor | c220a18 | 2010-04-19 18:02:19 +0000 | [diff] [blame] | 155 | |
Douglas Gregor | 53e4b55 | 2010-10-26 17:18:00 +0000 | [diff] [blame] | 156 | #ifdef NON_FIXITS |
Douglas Gregor | 808bedf | 2010-10-26 18:25:19 +0000 | [diff] [blame] | 157 | @interface Sub3 : Super |
| 158 | - (int)method3; |
| 159 | @end |
| 160 | |
| 161 | @implementation Sub3 |
| 162 | - (int)method3 { |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 163 | int x = super; // expected-error{{use of undeclared identifier 'super'}} |
Douglas Gregor | 53e4b55 | 2010-10-26 17:18:00 +0000 | [diff] [blame] | 164 | return 0; |
| 165 | } |
| 166 | @end |
| 167 | #endif |