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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [obj-c++.dg/] [lookup-2.mm] - Blame information for rev 826

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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