| 1 |
/* Test for situations in which protocol conformance information |
| 2 |
may be lost, leading to superfluous warnings. */ |
| 3 |
/* Author: Ziemowit Laski <[email protected]>. */ |
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-additional-options "-Wno-objc-root-class" } */ |
| 6 |
|
| 7 |
/* One-line substitute for objc/objc.h */ |
| 8 |
typedef struct objc_object { struct objc_class *class_pointer; } *id; |
| 9 |
|
| 10 |
@protocol NSObject |
| 11 |
- (int)someValue; |
| 12 |
@end |
| 13 |
|
| 14 |
@interface NSObject <NSObject> |
| 15 |
@end |
| 16 |
|
| 17 |
@protocol PlateMethods |
| 18 |
- (void)someMethod; |
| 19 |
@end |
| 20 |
|
| 21 |
@interface Foo { |
| 22 |
NSObject <PlateMethods> *plate; |
| 23 |
id <PlateMethods> plate1; |
| 24 |
NSObject *plate2; |
| 25 |
} |
| 26 |
- (id <PlateMethods>) getPlate; |
| 27 |
- (id <NSObject>) getPlate1; |
| 28 |
- (int) getValue; |
| 29 |
@end |
| 30 |
|
| 31 |
@implementation Foo |
| 32 |
- (id <PlateMethods>) getPlate { |
| 33 |
return plate; /* { dg-bogus "does not implement" } */ |
| 34 |
} |
| 35 |
- (id <NSObject>) getPlate1 { |
| 36 |
return (id <NSObject>)plate1; /* { dg-bogus "does not conform" } */ |
| 37 |
} |
| 38 |
- (int) getValue { |
| 39 |
int i = [plate1 someValue]; /* { dg-warning ".\\-someValue. not found in protocol\\(s\\)" } */ |
| 40 |
|
| 41 |
int j = [(id <NSObject>)plate1 someValue]; /* { dg-bogus "not found in protocol" } */ |
| 42 |
int k = [(id)plate1 someValue]; /* { dg-bogus "not found in protocol" } */ |
| 43 |
return i + j + k; |
| 44 |
} |
| 45 |
@end |