OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [protocol-inheritance-1.m] - Blame information for rev 704

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 704 jeremybenn
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2
/* { dg-do compile } */
3
/* { dg-options "-Wno-protocol" } */
4
 
5
#include <objc/objc.h>
6
 
7
/* Test the -Wno-protocol flag.  With this, at a class is accepted
8
   (with no warnings) as conforming to a protocol even if some
9
   protocol methods are implemented in the superclass.  */
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
   but that still makes it conform to the protocol.  No warnings.  */
36
@interface MySubClass : MyRootClass <MyProtocol>
37
@end
38
 
39
@implementation MySubClass
40
@end /* No warnings here.  */
41
 
42
 
43
/* The subclass instead does not inherit the method method2 (and does
44
   not implement it directly) so it does not conform to the
45
   protocol MyProtocol2.  */
46
@interface MySubClass2 : MyRootClass <MyProtocol2>
47
@end
48
 
49
@implementation MySubClass2
50
@end /* Warnings here, below.  */
51
 
52
/* { dg-warning "incomplete implementation of class .MySubClass2." "" { target *-*-* } 50 } */
53
/* { dg-warning "method definition for .\\-method2. not found" "" { target *-*-* } 50 } */
54
/* { dg-warning "class .MySubClass2. does not fully implement the .MyProtocol2. protocol" "" { target *-*-* } 50 } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.