blob: 381233f95c29a4187417e46e69a56aaee69b5dc8 [file] [log] [blame]
Patrick Beardb2f68202012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify -Wno-objc-root-class %s
Douglas Gregor312eadb2011-04-24 05:37:28 +00002// RUN: cp %s %t
Patrick Beardb2f68202012-04-06 18:12:22 +00003// 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 Gregor312eadb2011-04-24 05:37:28 +00005// RUN: grep "@implementation Sub3" %t
Douglas Gregorc37b7362010-10-26 23:34:31 +00006
Douglas Gregor312eadb2011-04-24 05:37:28 +00007@interface NSString // expected-note 2{{'NSString' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +00008+ (int)method:(int)x;
Douglas Gregord203a162010-01-01 00:15:04 +00009@end
10
11void test() {
Douglas Gregor6add6fb2011-04-27 04:02:56 +000012 NSstring *str = @"A string"; // expected-error{{unknown type name 'NSstring'; did you mean 'NSString'?}}
Douglas Gregord203a162010-01-01 00:15:04 +000013}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000014
15@protocol P1
Fariborz Jahanian3ac1eda2010-01-20 01:51:55 +000016@optional
Douglas Gregor67dd1d42010-01-07 00:17:44 +000017@property int *sprop; // expected-note{{'sprop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000018@end
19
20@interface A
21{
Douglas Gregor67dd1d42010-01-07 00:17:44 +000022 int his_ivar; // expected-note 2{{'his_ivar' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000023 float wibble;
24}
Douglas Gregorde037c22010-05-31 14:58:57 +000025- (void)methodA;
26+ (void)methodA;
Douglas Gregor67dd1d42010-01-07 00:17:44 +000027@property int his_prop; // expected-note{{'his_prop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000028@end
29
30@interface B : A <P1>
31{
Douglas Gregor67dd1d42010-01-07 00:17:44 +000032 int her_ivar; // expected-note 2{{'her_ivar' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000033}
34
Douglas Gregor67dd1d42010-01-07 00:17:44 +000035@property int her_prop; // expected-note{{'her_prop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000036- (void)inst_method1:(int)a;
37+ (void)class_method1;
38@end
39
40@implementation A
41@synthesize his_prop = his_ivar;
Douglas Gregorde037c22010-05-31 14:58:57 +000042- (void)methodA { }
43+ (void)methodA { }
Douglas Gregorf06cdae2010-01-03 18:01:57 +000044@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
63void test_message_send(B* b) {
Douglas Gregor47bd5432010-04-14 02:46:37 +000064 [NSstring method:17]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000065}
66
Douglas Gregor67dd1d42010-01-07 00:17:44 +000067@interface Collide // expected-note{{'Collide' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000068{
69@public
Douglas Gregor67dd1d42010-01-07 00:17:44 +000070 int value; // expected-note{{'value' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000071}
72
Douglas Gregor67dd1d42010-01-07 00:17:44 +000073@property int value; // expected-note{{'value' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000074@end
75
76@implementation Collide
77@synthesize value = value;
78@end
79
80void 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 Kremeneke2aaf392010-05-17 23:03:33 +000085#ifdef NON_FIXITS
Douglas Gregorf06cdae2010-01-03 18:01:57 +000086@interface Derived : Collid // expected-error{{cannot find interface declaration for 'Collid', superclass of 'Derived'; did you mean 'Collide'?}}
87@end
Ted Kremeneke2aaf392010-05-17 23:03:33 +000088#endif
Douglas Gregorf06cdae2010-01-03 18:01:57 +000089
Ted Kremeneke2aaf392010-05-17 23:03:33 +000090#ifdef NON_FIXITS
Douglas Gregor67dd1d42010-01-07 00:17:44 +000091@protocol NetworkSocket // expected-note{{'NetworkSocket' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000092- (int)send:(void*)buffer bytes:(int)bytes;
93@end
94
Douglas Gregor62021192010-02-04 23:42:48 +000095@interface IPv6 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000096@end
Ted Kremeneke2aaf392010-05-17 23:03:33 +000097#endif
Douglas Gregoraaf87162010-04-14 20:04:41 +000098
99@interface Super
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000100- (int)method; // expected-note{{using}}
Douglas Gregor91f7ac72010-05-18 16:14:23 +0000101- (int)method2;
Douglas Gregor53e4b552010-10-26 17:18:00 +0000102- (int)method3:(id)x;
Douglas Gregoraaf87162010-04-14 20:04:41 +0000103@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 Gregorc220a182010-04-19 18:02:19 +0000115
Douglas Gregor91f7ac72010-05-18 16:14:23 +0000116double *isupper(int);
117
118@interface Sub2 : Super
119- (int)method2;
120@end
121
122@implementation Sub2
123- (int)method2 {
Douglas Gregord0785ea2010-05-18 16:30:22 +0000124 return [supper method2]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}}
Douglas Gregor91f7ac72010-05-18 16:14:23 +0000125}
126@end
Douglas Gregor91f7ac72010-05-18 16:14:23 +0000127
Douglas Gregorc220a182010-04-19 18:02:19 +0000128@interface Ivar
129@end
130
131@protocol Proto
132@property (retain) id ivar;
133@end
134
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000135#ifdef NON_FIXITS
Douglas Gregorc220a182010-04-19 18:02:19 +0000136@interface User <Proto>
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000137- (void)method; // expected-note{{also found}}
Douglas Gregorc220a182010-04-19 18:02:19 +0000138@end
139
140@implementation User
Douglas Gregora1d1c752010-05-18 16:57:36 +0000141@synthesize ivar;
Douglas Gregorc220a182010-04-19 18:02:19 +0000142
143- (void)method {
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000144 // Test that we don't correct 'ivar' to 'Ivar' e
145 [ivar method]; // expected-warning{{multiple methods named 'method' found}}
Douglas Gregorc220a182010-04-19 18:02:19 +0000146}
147@end
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000148#endif
Douglas Gregorc220a182010-04-19 18:02:19 +0000149
Douglas Gregor1b730e82010-05-31 14:40:22 +0000150void f(A *a) {
151 f(a) // expected-error{{expected ';' after expression}}
Douglas Gregorde037c22010-05-31 14:58:57 +0000152 [a methodA] // expected-error{{expected ';' after expression}}
153 [A methodA] // expected-error{{expected ';' after expression}}
Douglas Gregor1b730e82010-05-31 14:40:22 +0000154}
Douglas Gregorc220a182010-04-19 18:02:19 +0000155
Douglas Gregor53e4b552010-10-26 17:18:00 +0000156#ifdef NON_FIXITS
Douglas Gregor808bedf2010-10-26 18:25:19 +0000157@interface Sub3 : Super
158- (int)method3;
159@end
160
161@implementation Sub3
162- (int)method3 {
Douglas Gregor312eadb2011-04-24 05:37:28 +0000163 int x = super; // expected-error{{use of undeclared identifier 'super'}}
Douglas Gregor53e4b552010-10-26 17:18:00 +0000164 return 0;
165}
166@end
167#endif