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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc/] [execute/] [exceptions/] [catchall-1.m] - Blame information for rev 702

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 702 jeremybenn
/* Test out '@catch(id foo) {...}', which should catch all uncaught
2
   exceptions.  */
3
/* Developed by Ziemowit Laski <zlaski@apple.com>.  */
4
 
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include "../../../objc-obj-c++-shared/TestsuiteObject.m"
8
 
9
/* The following is not required in actual user code; we include it
10
   here to check that the compiler generates an internal definition of
11
   _setjmp that is consistent with what <setjmp.h> provides.  */
12
#include <setjmp.h>
13
 
14
#define CHECK_IF(expr) if(!(expr)) abort()
15
 
16
@interface Frob: TestsuiteObject
17
@end
18
 
19
@implementation Frob: TestsuiteObject
20
@end
21
 
22
static Frob* _connection = nil;
23
 
24
//--------------------------------------------------------------------
25
 
26
 
27
void test (TestsuiteObject* sendPort)
28
{
29
        int cleanupPorts = 1;
30
        Frob* receivePort = nil;
31
 
32
        @try {
33
                printf ("receivePort = %p\n", receivePort);
34
                printf ("sendPort = %p\n", sendPort);
35
                printf ("cleanupPorts = %d\n", cleanupPorts);
36
                printf ("---\n");
37
 
38
                receivePort = (Frob *) -1;
39
                _connection = (Frob *) -1;
40
                printf ("receivePort = %p\n", receivePort);
41
                printf ("sendPort = %p\n", sendPort);
42
                printf ("cleanupPorts = %d\n", cleanupPorts);
43
                printf ("---\n");
44
 
45
                receivePort = nil;
46
                sendPort = nil;
47
                cleanupPorts = 0;
48
 
49
                printf ("receivePort = %p\n", receivePort);
50
                printf ("sendPort = %p\n", sendPort);
51
                printf ("cleanupPorts = %d\n", cleanupPorts);
52
                printf ("---\n");
53
 
54
                @throw [TestsuiteObject new];
55
        }
56
        @catch(Frob *obj) {
57
                printf ("Exception caught by incorrect handler!\n");
58
                CHECK_IF(0);
59
        }
60
        @catch(id exc) {
61
                printf ("Exception caught by correct handler.\n");
62
                printf ("receivePort = %p (expected 0x0)\n", receivePort);
63
                printf ("sendPort = %p (expected 0x0)\n", sendPort);
64
                printf ("cleanupPorts = %d (expected 0)\n", cleanupPorts);
65
                printf ("---");
66
                CHECK_IF(!receivePort);
67
                CHECK_IF(!sendPort);
68
                CHECK_IF(!cleanupPorts);
69
        }
70
}
71
 
72
int main (void) {
73
 
74
        test((TestsuiteObject *)-1);
75
        return 0;
76
}
77
 

powered by: WebSVN 2.1.0

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