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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [protocol-optional-1.mm] - Blame information for rev 703

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Contributed by Nicola Pero , November 2010.  */
2
/* { dg-do compile } */
3
 
4
#include 
5
 
6
/* Test that @optional for @protocol works.  */
7
 
8
@protocol MyProtocol
9
+ (int)classMethod;
10
- (int)method;
11
@optional
12
+ (int)optionalClassMethod;
13
- (int)optionalMethod;
14
@end
15
 
16
@interface MyRootClass 
17
@end
18
 
19
/* The implementation implements both the @required methods, but none
20
   of the @optional ones.  There should be no warnings as the
21
   @optional methods are optional. ;-)  */
22
@implementation MyRootClass
23
+ (int)classMethod
24
{
25
  return 20;
26
}
27
- (int)method
28
{
29
  return 11;
30
}
31
@end
32
 
33
int function (id  object1,
34
              MyRootClass *object2)
35
{
36
  /* Test that there are no warnings if you try to use an @optional
37
     method with an object of the class.  */
38
  int i = 0;
39
 
40
  i += [object1 method];
41
  i += [object2 method];
42
  i += [MyRootClass classMethod];
43
  i += [object1 optionalMethod];
44
  i += [object2 optionalMethod];
45
  i += [MyRootClass optionalClassMethod];
46
 
47
  return i;
48
}

powered by: WebSVN 2.1.0

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