| 1 |
/* Contributed by Nicola Pero <[email protected]>, November 2010. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
|
| 4 |
/* Test that protocol qualifiers work in the same way with @class and @interface. */ |
| 5 |
|
| 6 |
#include <objc/objc.h> |
| 7 |
|
| 8 |
@protocol MyProtocol |
| 9 |
- (void) method; |
| 10 |
@end |
| 11 |
|
| 12 |
|
| 13 |
/* This first snippet gives no warnings, which is correct as 'object' |
| 14 |
implements <MyProtocol> and hence responds to 'method'. Note how |
| 15 |
the details of the class 'MyClass' are never used. */ |
| 16 |
@interface MyClass |
| 17 |
@end |
| 18 |
|
| 19 |
void test (MyClass <MyProtocol> *object) |
| 20 |
{ |
| 21 |
[object method]; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
/* This second snippet should behave identically. 'object' still implements |
| 26 |
the same protocol and responds to 'method'. The details of MyClass or |
| 27 |
MyClass2 are irrelevant. */ |
| 28 |
@class MyClass2; |
| 29 |
|
| 30 |
void test2 (MyClass2 <MyProtocol> *object) |
| 31 |
{ |
| 32 |
[object method]; |
| 33 |
} |