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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [try-catch-2.mm] - Blame information for rev 703

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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