Debian Codegraph @

clang/test/SemaObjC/unqualified-to-qualified-class-warn.m

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
3 @protocol Fooable
4 - (void)foo;
5 @end
6
7 @protocol SubFooable <Fooable>
8 @end
9
10 @interface AClass
11 @end
12
13 @interface BClass : AClass <SubFooable>
14 @end
15
16 @implementation BClass
17 - (void)foo {
18 }
19 @end
20
21 void functionTakingAClassConformingToAProtocol(AClass <Fooable> *instance) { // expected-note {{passing argument to parameter 'instance' here}}
22 }
23
24 int main (void) {
25 AClass *aobject = 0;
26 BClass *bobject = 0;
27 functionTakingAClassConformingToAProtocol(aobject); // expected-error {{incompatible pointer types passing 'AClass *' to parameter of type 'AClass<Fooable> *'}}
28 functionTakingAClassConformingToAProtocol(bobject); // Shouldn't warn - does implement Fooable
29 return 0;
30 }
31
32 @interface NSObject @end
33
34 @protocol MyProtocol
35 @end
36
37 @interface MyClass : NSObject
38 {
39 }
40 @end
41
42 @implementation MyClass
43 @end
44
45 @interface MySubclass : MyClass <MyProtocol>
46 {
47 }
48 @end
49
50 @interface MyTestClass : NSObject
51 {
52 @private
53 NSObject <MyProtocol> *someObj;
54 }
55
56 @property (nonatomic, assign) NSObject <MyProtocol> *someObj;
57
58 @end
59
60 @implementation MyTestClass
61
62 @synthesize someObj;
63
64 - (void)someMethod
65 {
66 MySubclass *foo;
67 [self setSomeObj:foo]; // no warning here!
68 }
69
70 @end