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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [obj-c++.dg/] [lookup-2.mm] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* { dg-do run } */
2
 
3
#include 
4
#include 
5
 
6
class MyWidget {
7
 public:
8
  int a;
9
  MyWidget(void) { a = 17; }
10
};
11
 
12
MyWidget gWidget;
13
 
14
@protocol MyProto
15
- (MyWidget *)widget;
16
@end
17
 
18
@interface Foo: Object
19
@end
20
 
21
@interface Bar: Foo 
22
@end
23
 
24
@interface Container: Object
25
+ (MyWidget *)elementForView:(Foo *)view;
26
@end
27
 
28
@implementation Foo
29
@end
30
 
31
@implementation Bar
32
- (MyWidget *)widget {
33
  return &gWidget;
34
}
35
@end
36
 
37
@implementation Container
38
+ (MyWidget *)elementForView:(Foo *)view
39
{
40
    MyWidget *widget = nil;
41
    if ([view conformsTo:@protocol(MyProto)]) {
42
        widget = [(Foo  *)view widget];
43
    }
44
    return widget;
45
}
46
@end
47
 
48
int main(void) {
49
  id view = [Bar new];
50
  MyWidget *w = [Container elementForView: view];
51
 
52
  if (!w || w->a != 17)
53
    abort ();
54
 
55
  return 0;
56
}

powered by: WebSVN 2.1.0

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