Debian Codegraph @

clang/test/SemaObjC/typo-correction.m

raw
1 // RUN: %clang_cc1 %s -verify -fsyntax-only -fobjc-runtime=ios
2
3 @protocol P
4 -(id)description;
5 @end
6
7 @interface B<P>
8 @property int x;
9 @end
10
11 @interface S : B {
12 id _someivar; // expected-note {{here}}
13 }
14 @end
15
16 // Spell-checking 'undefined' is ok.
17 undefined var; // expected-error {{unknown type name}}
18
19 typedef int super1;
20 @implementation S
21 -(void)foo:(id)p1 other:(id)p2 {
22 // Spell-checking 'super' is not ok.
23 super.x = 0;
24 self.x = 0;
25 }
26
27 -(void)test {
28 [self foo:[super description] other:someivar]; // expected-error {{use of undeclared identifier 'someivar'; did you mean '_someivar'?}}
29 }
30 @end
31
32 __attribute__ (( __objc_root_class__ ))
33 @interface I {
34 id _interface; // expected-note {{'_interface' declared here}}
35 }
36 -(void)method;
37 @end
38
39 @interface I () {
40 id _extension; // expected-note {{'_extension' declared here}}
41 }
42 @end
43
44 @implementation I {
45 id _implementation; // expected-note {{'_implementation' declared here}}
46 }
47 -(void)method {
48 (void)self->implementation; // expected-error {{'I' does not have a member named 'implementation'; did you mean '_implementation'?}}
49 (void)self->interface; // expected-error {{'I' does not have a member named 'interface'; did you mean '_interface'?}}
50 (void)self->extension; // expected-error {{'I' does not have a member named 'extension'; did you mean '_extension'?}}
51 }
52 @end
53
54 // Typo correction for a property when it has as correction candidates
55 // synthesized ivar and a class name, both at the same edit distance.
56 @class TypoCandidate;
57
58 __attribute__ (( __objc_root_class__ ))
59 @interface PropertyType
60 @property int x;
61 @end
62
63 __attribute__ (( __objc_root_class__ ))
64 @interface InterfaceC
65 @property(assign) PropertyType *typoCandidate; // expected-note {{'_typoCandidate' declared here}}
66 @end
67
68 @implementation InterfaceC
69 -(void)method {
70 typoCandidate.x = 0; // expected-error {{use of undeclared identifier 'typoCandidate'; did you mean '_typoCandidate'?}}
71 }
72 @end