PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / objc.dg / protocol-inheritance-2.m
blob74c9174b5de71d6210ee17a252a89472a15ff973
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-do compile } */
4 #include <objc/objc.h>
6 /* Test standard warnings when a class conforms to a protocol but some
7    methods are implemented in the superclass.  Use -Wno-protocol to
8    turn these off.  */
10 @protocol MyProtocol
11 - (int)method;
12 @end
14 @protocol MyProtocol2
15 - (int)method2;
16 @end
18 /* The superclass implements the method required by the protocol.  */
19 @interface MyRootClass
21   Class isa;
23 - (int)method;
24 @end
26 @implementation MyRootClass
27 - (int)method
29   return 23;
31 @end
33 /* The subclass inherits the method (does not implement it directly)
34    and unless -Wno-protocol is used, we emit a warning.  */
35 @interface MySubClass : MyRootClass <MyProtocol>
36 @end
38 @implementation MySubClass
39 @end
40 /* { dg-warning "incomplete implementation of class .MySubClass." "" { target *-*-* } .-1 } */
41 /* { dg-warning "method definition for .\\-method. not found" "" { target *-*-* } .-2 } */
42 /* { dg-warning "class .MySubClass. does not fully implement the .MyProtocol. protocol" "" { target *-*-* } .-3 } */
45 /* The subclass instead does not inherit the method method2 (and does
46    not implement it directly) so it does not conform to the
47    protocol MyProtocol2.  */
48 @interface MySubClass2 : MyRootClass <MyProtocol2>
49 @end
51 @implementation MySubClass2
52 @end /* Warnings here, below.  */
53 /* { dg-warning "incomplete implementation of class .MySubClass2." "" { target *-*-* } .-1 } */
54 /* { dg-warning "method definition for .\\-method2. not found" "" { target *-*-* } .-2 } */
55 /* { dg-warning "class .MySubClass2. does not fully implement the .MyProtocol2. protocol" "" { target *-*-* } .-3 } */