blob: 9a25a026e56e05c95aa06a0850175bfc5feacb92 [file] [log] [blame]
Ted Kremeneke2aaf392010-05-17 23:03:33 +00001// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -DNON_FIXITS -verify %s
Daniel Dunbarb63ff722010-10-15 15:13:02 +00002// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -E -P %s -o %t
Douglas Gregor91f7ac72010-05-18 16:14:23 +00003// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fixit %t || true
Ted Kremeneke2aaf392010-05-17 23:03:33 +00004// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -pedantic -Werror %t
Douglas Gregord203a162010-01-01 00:15:04 +00005
Douglas Gregor47bd5432010-04-14 02:46:37 +00006@interface NSString // expected-note{{'NSString' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +00007+ (int)method:(int)x;
Douglas Gregord203a162010-01-01 00:15:04 +00008@end
9
Ted Kremeneke2aaf392010-05-17 23:03:33 +000010#ifdef NON_FIXITS
Douglas Gregord203a162010-01-01 00:15:04 +000011void test() {
Douglas Gregorf06cdae2010-01-03 18:01:57 +000012 // FIXME: not providing fix-its
Douglas Gregor837e7382010-09-17 23:01:08 +000013 NSstring *str = @"A string"; // expected-error{{use of undeclared identifier 'NSstring'; did you mean 'NSString'?}} \
14 // expected-error{{use of undeclared identifier 'str'}}
Douglas Gregord203a162010-01-01 00:15:04 +000015}
Ted Kremeneke2aaf392010-05-17 23:03:33 +000016#endif
Douglas Gregorf06cdae2010-01-03 18:01:57 +000017
18@protocol P1
Fariborz Jahanian3ac1eda2010-01-20 01:51:55 +000019@optional
Douglas Gregor67dd1d42010-01-07 00:17:44 +000020@property int *sprop; // expected-note{{'sprop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000021@end
22
23@interface A
24{
Douglas Gregor67dd1d42010-01-07 00:17:44 +000025 int his_ivar; // expected-note 2{{'his_ivar' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000026 float wibble;
27}
Douglas Gregorde037c22010-05-31 14:58:57 +000028- (void)methodA;
29+ (void)methodA;
Douglas Gregor67dd1d42010-01-07 00:17:44 +000030@property int his_prop; // expected-note{{'his_prop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000031@end
32
33@interface B : A <P1>
34{
Douglas Gregor67dd1d42010-01-07 00:17:44 +000035 int her_ivar; // expected-note 2{{'her_ivar' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000036}
37
Douglas Gregor67dd1d42010-01-07 00:17:44 +000038@property int her_prop; // expected-note{{'her_prop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000039- (void)inst_method1:(int)a;
40+ (void)class_method1;
41@end
42
43@implementation A
44@synthesize his_prop = his_ivar;
Douglas Gregorde037c22010-05-31 14:58:57 +000045- (void)methodA { }
46+ (void)methodA { }
Douglas Gregorf06cdae2010-01-03 18:01:57 +000047@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
66void test_message_send(B* b) {
Douglas Gregor47bd5432010-04-14 02:46:37 +000067 [NSstring method:17]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000068}
69
Douglas Gregor67dd1d42010-01-07 00:17:44 +000070@interface Collide // expected-note{{'Collide' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000071{
72@public
Douglas Gregor67dd1d42010-01-07 00:17:44 +000073 int value; // expected-note{{'value' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000074}
75
Douglas Gregor67dd1d42010-01-07 00:17:44 +000076@property int value; // expected-note{{'value' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000077@end
78
79@implementation Collide
80@synthesize value = value;
81@end
82
83void 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 Kremeneke2aaf392010-05-17 23:03:33 +000088#ifdef NON_FIXITS
Douglas Gregorf06cdae2010-01-03 18:01:57 +000089@interface Derived : Collid // expected-error{{cannot find interface declaration for 'Collid', superclass of 'Derived'; did you mean 'Collide'?}}
90@end
Ted Kremeneke2aaf392010-05-17 23:03:33 +000091#endif
Douglas Gregorf06cdae2010-01-03 18:01:57 +000092
Ted Kremeneke2aaf392010-05-17 23:03:33 +000093#ifdef NON_FIXITS
Douglas Gregor67dd1d42010-01-07 00:17:44 +000094@protocol NetworkSocket // expected-note{{'NetworkSocket' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000095- (int)send:(void*)buffer bytes:(int)bytes;
96@end
97
Douglas Gregor62021192010-02-04 23:42:48 +000098@interface IPv6 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000099@end
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000100#endif
Douglas Gregoraaf87162010-04-14 20:04:41 +0000101
102@interface Super
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000103- (int)method; // expected-note{{using}}
Douglas Gregor91f7ac72010-05-18 16:14:23 +0000104- (int)method2;
Douglas Gregor53e4b552010-10-26 17:18:00 +0000105- (int)method3:(id)x;
Douglas Gregoraaf87162010-04-14 20:04:41 +0000106@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 Gregorc220a182010-04-19 18:02:19 +0000118
Douglas Gregor91f7ac72010-05-18 16:14:23 +0000119double *isupper(int);
120
121@interface Sub2 : Super
122- (int)method2;
123@end
124
125@implementation Sub2
126- (int)method2 {
Douglas Gregord0785ea2010-05-18 16:30:22 +0000127 return [supper method2]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}}
Douglas Gregor91f7ac72010-05-18 16:14:23 +0000128}
129@end
Douglas Gregor91f7ac72010-05-18 16:14:23 +0000130
Douglas Gregorc220a182010-04-19 18:02:19 +0000131@interface Ivar
132@end
133
134@protocol Proto
135@property (retain) id ivar;
136@end
137
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000138#ifdef NON_FIXITS
Douglas Gregorc220a182010-04-19 18:02:19 +0000139@interface User <Proto>
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000140- (void)method; // expected-note{{also found}}
Douglas Gregorc220a182010-04-19 18:02:19 +0000141@end
142
143@implementation User
Douglas Gregora1d1c752010-05-18 16:57:36 +0000144@synthesize ivar;
Douglas Gregorc220a182010-04-19 18:02:19 +0000145
146- (void)method {
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000147 // Test that we don't correct 'ivar' to 'Ivar' e
148 [ivar method]; // expected-warning{{multiple methods named 'method' found}}
Douglas Gregorc220a182010-04-19 18:02:19 +0000149}
150@end
Ted Kremeneke2aaf392010-05-17 23:03:33 +0000151#endif
Douglas Gregorc220a182010-04-19 18:02:19 +0000152
Douglas Gregor1b730e82010-05-31 14:40:22 +0000153void f(A *a) {
154 f(a) // expected-error{{expected ';' after expression}}
Douglas Gregorde037c22010-05-31 14:58:57 +0000155 [a methodA] // expected-error{{expected ';' after expression}}
156 [A methodA] // expected-error{{expected ';' after expression}}
Douglas Gregor1b730e82010-05-31 14:40:22 +0000157}
Douglas Gregorc220a182010-04-19 18:02:19 +0000158
Douglas Gregor53e4b552010-10-26 17:18:00 +0000159#ifdef NON_FIXITS
Douglas Gregor808bedf2010-10-26 18:25:19 +0000160@interface Sub3 : Super
161- (int)method3;
162@end
163
164@implementation Sub3
165- (int)method3 {
Douglas Gregor53e4b552010-10-26 17:18:00 +0000166 int x = super; // expected-note{{use of undeclared identifier 'super'; did you mean 'Super'?}}
167 return 0;
168}
169@end
170#endif