Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / obj-c++.dg / lookup-2.mm
blobf694ec9301c330015cc8cb6c1255a00c4361c4f8
1 /* { dg-do run } */
3 #include <objc/Object.h>
4 #include <stdlib.h>
6 class MyWidget {
7  public:
8   int a;
9   MyWidget(void) { a = 17; }
12 MyWidget gWidget;
14 @protocol MyProto
15 - (MyWidget *)widget;
16 @end
18 @interface Foo: Object
19 @end
21 @interface Bar: Foo <MyProto>
22 @end
24 @interface Container: Object
25 + (MyWidget *)elementForView:(Foo *)view;
26 @end
28 @implementation Foo
29 @end
31 @implementation Bar
32 - (MyWidget *)widget {
33   return &gWidget;
35 @end
37 @implementation Container
38 + (MyWidget *)elementForView:(Foo *)view
40     MyWidget *widget = nil;
41     if ([view conformsTo:@protocol(MyProto)]) {
42         widget = [(Foo <MyProto> *)view widget];
43     }
44     return widget;
46 @end
48 int main(void) {
49   id view = [Bar new];
50   MyWidget *w = [Container elementForView: view];
52   if (!w || w->a != 17)
53     abort ();
55   return 0;