| 1 |
/* Contributed by Nicola Pero <[email protected]>, November 2010. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-additional-options "-Wno-objc-root-class" } */ |
| 4 |
|
| 5 |
#include <objc/objc.h> |
| 6 |
|
| 7 |
/* Test standard warnings when a class conforms to a protocol but some |
| 8 |
methods are implemented in the superclass. Use -Wno-protocol to |
| 9 |
turn these off. */ |
| 10 |
|
| 11 |
@protocol MyProtocol |
| 12 |
- (int)method; |
| 13 |
@end |
| 14 |
|
| 15 |
@protocol MyProtocol2 |
| 16 |
- (int)method2; |
| 17 |
@end |
| 18 |
|
| 19 |
/* The superclass implements the method required by the protocol. */ |
| 20 |
@interface MyRootClass |
| 21 |
{ |
| 22 |
Class isa; |
| 23 |
} |
| 24 |
- (int)method; |
| 25 |
@end |
| 26 |
|
| 27 |
@implementation MyRootClass |
| 28 |
- (int)method |
| 29 |
{ |
| 30 |
return 23; |
| 31 |
} |
| 32 |
@end |
| 33 |
|
| 34 |
/* The subclass inherits the method (does not implement it directly) |
| 35 |
and unless -Wno-protocol is used, we emit a warning. */ |
| 36 |
@interface MySubClass : MyRootClass <MyProtocol> |
| 37 |
@end |
| 38 |
|
| 39 |
@implementation MySubClass |
| 40 |
@end |
| 41 |
/* { dg-warning "incomplete implementation of class .MySubClass." "" { target *-*-* } .-1 } */ |
| 42 |
/* { dg-warning "method definition for .\\-method. not found" "" { target *-*-* } .-2 } */ |
| 43 |
/* { dg-warning "class .MySubClass. does not fully implement the .MyProtocol. protocol" "" { target *-*-* } .-3 } */ |
| 44 |
|
| 45 |
|
| 46 |
/* The subclass instead does not inherit the method method2 (and does |
| 47 |
not implement it directly) so it does not conform to the |
| 48 |
protocol MyProtocol2. */ |
| 49 |
@interface MySubClass2 : MyRootClass <MyProtocol2> |
| 50 |
@end |
| 51 |
|
| 52 |
@implementation MySubClass2 |
| 53 |
@end /* Warnings here, below. */ |
| 54 |
/* { dg-warning "incomplete implementation of class .MySubClass2." "" { target *-*-* } .-1 } */ |
| 55 |
/* { dg-warning "method definition for .\\-method2. not found" "" { target *-*-* } .-2 } */ |
| 56 |
/* { dg-warning "class .MySubClass2. does not fully implement the .MyProtocol2. protocol" "" { target *-*-* } .-3 } */ |