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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [obj-c++.dg/] [except-1.mm] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-do run } */
2
 
3
/* This tests that exceptions work.  It used to fail because
4
   objc_msgSend was marked with DECL_NOTHROW.
5
   If you include objc/Object.h, the problem goes away, because
6
   that file includes objc/objc-runtime.h which explicitly prototypes
7
   objc_msgSend without 'nothrow'.  */
8
 
9
#include 
10
#include 
11
 
12
 
13
@interface Object {
14
  Class isa;
15
}
16
+ alloc;
17
- init;
18
@end
19
 
20
// ObjectiveC class header
21
@interface ObjCclass : Object {
22
}
23
-(void)method1;
24
-(void)method2;
25
@end
26
 
27
// C++ class header
28
class CPPclass {
29
public:
30
        void function1();
31
};
32
 
33
 
34
// Main
35
int main(int argc, char *argv[])
36
{
37
        ObjCclass * foo = [[ObjCclass alloc] init];
38
        [foo method1];
39
        exit (0);
40
}
41
 
42
 
43
// ObjectiveC implementation
44
@implementation ObjCclass
45
 
46
-(void) method1
47
{
48
        try {
49
                [self method2];
50
        }
51
        catch(...) {
52
                return;
53
        }
54
}
55
 
56
-(void) method2
57
{
58
        CPPclass foo;
59
        foo.function1();
60
}
61
 
62
@end
63
 
64
 
65
// C++ implementation
66
void CPPclass::function1()
67
{
68
        throw (1);
69
        /* Shouldn't be here because we threw.  */
70
        abort ();
71
}

powered by: WebSVN 2.1.0

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