blob: 86dd383c904e7276aee4ce7f911a90515091ffbc [file] [log] [blame]
Douglas Gregord203a162010-01-01 00:15:04 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregorf06cdae2010-01-03 18:01:57 +00002// FIXME: the test below isn't testing quite what we want...
Douglas Gregor736fc1b2010-01-01 17:23:17 +00003// RUN: %clang_cc1 -fsyntax-only -fixit -o - %s | %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c -
Douglas Gregord203a162010-01-01 00:15:04 +00004
5@interface NSString
Douglas Gregorf06cdae2010-01-03 18:01:57 +00006+ (int)method:(int)x;
Douglas Gregord203a162010-01-01 00:15:04 +00007@end
8
9void test() {
Douglas Gregorf06cdae2010-01-03 18:01:57 +000010 // FIXME: not providing fix-its
Douglas Gregord203a162010-01-01 00:15:04 +000011 NSstring *str = @"A string"; // expected-error{{use of undeclared identifier 'NSstring'; did you mean 'NSString'?}}
12}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000013
14@protocol P1
Fariborz Jahanian3ac1eda2010-01-20 01:51:55 +000015@optional
Douglas Gregor67dd1d42010-01-07 00:17:44 +000016@property int *sprop; // expected-note{{'sprop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000017@end
18
19@interface A
20{
Douglas Gregor67dd1d42010-01-07 00:17:44 +000021 int his_ivar; // expected-note 2{{'his_ivar' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000022 float wibble;
23}
24
Douglas Gregor67dd1d42010-01-07 00:17:44 +000025@property int his_prop; // expected-note{{'his_prop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000026@end
27
28@interface B : A <P1>
29{
Douglas Gregor67dd1d42010-01-07 00:17:44 +000030 int her_ivar; // expected-note 2{{'her_ivar' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000031}
32
Douglas Gregor67dd1d42010-01-07 00:17:44 +000033@property int her_prop; // expected-note{{'her_prop' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000034- (void)inst_method1:(int)a;
35+ (void)class_method1;
36@end
37
38@implementation A
39@synthesize his_prop = his_ivar;
40@end
41
42@implementation B
43@synthesize her_prop = her_ivar;
44
45-(void)inst_method1:(int)a {
46 herivar = a; // expected-error{{use of undeclared identifier 'herivar'; did you mean 'her_ivar'?}}
47 hisivar = a; // expected-error{{use of undeclared identifier 'hisivar'; did you mean 'his_ivar'?}}
48 self->herivar = a; // expected-error{{'B' does not have a member named 'herivar'; did you mean 'her_ivar'?}}
49 self->hisivar = a; // expected-error{{'B' does not have a member named 'hisivar'; did you mean 'his_ivar'?}}
50 self.hisprop = 0; // expected-error{{property 'hisprop' not found on object of type 'B *'; did you mean 'his_prop'?}}
51 self.herprop = 0; // expected-error{{property 'herprop' not found on object of type 'B *'; did you mean 'her_prop'?}}
52 self.s_prop = 0; // expected-error{{property 's_prop' not found on object of type 'B *'; did you mean 'sprop'?}}
53}
54
55+(void)class_method1 {
56}
57@end
58
59void test_message_send(B* b) {
60 // FIXME: Not providing fix-its
61 [NSstring method:17]; // expected-error{{use of undeclared identifier 'NSstring'; did you mean 'NSString'?}}
62}
63
Douglas Gregor67dd1d42010-01-07 00:17:44 +000064@interface Collide // expected-note{{'Collide' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000065{
66@public
Douglas Gregor67dd1d42010-01-07 00:17:44 +000067 int value; // expected-note{{'value' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000068}
69
Douglas Gregor67dd1d42010-01-07 00:17:44 +000070@property int value; // expected-note{{'value' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000071@end
72
73@implementation Collide
74@synthesize value = value;
75@end
76
77void test2(Collide *a) {
78 a.valu = 17; // expected-error{{property 'valu' not found on object of type 'Collide *'; did you mean 'value'?}}
79 a->vale = 17; // expected-error{{'Collide' does not have a member named 'vale'; did you mean 'value'?}}
80}
81
82@interface Derived : Collid // expected-error{{cannot find interface declaration for 'Collid', superclass of 'Derived'; did you mean 'Collide'?}}
83@end
84
Douglas Gregor67dd1d42010-01-07 00:17:44 +000085@protocol NetworkSocket // expected-note{{'NetworkSocket' declared here}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000086- (int)send:(void*)buffer bytes:(int)bytes;
87@end
88
Douglas Gregor62021192010-02-04 23:42:48 +000089@interface IPv6 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}}
Douglas Gregorf06cdae2010-01-03 18:01:57 +000090@end