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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Contributed by Nicola Pero , November 2010.  */
2
 
3
/* FIXME: This does not test running the code, because Objective-C exceptions at the moment
4
   do not execute correctly in Objective-C++.  See PR objc++/23616.  Once that is fixed,
5
   this test should be changed to use 'dg-do run' instead of just 'dg-do compile'.  */
6
/* { dg-do compile } */
7
/* { dg-options "-fobjc-exceptions" } */
8
 
9
/* This test checks the syntax @catch (...) which catches any
10
   exceptions.  Check that code using it runs correctly.  */
11
 
12
#include "../objc-obj-c++-shared/TestsuiteObject.m"
13
#include 
14
 
15
@interface MyObject : TestsuiteObject
16
@end
17
 
18
@implementation MyObject
19
@end
20
 
21
int test (id object)
22
{
23
  int i = 0;
24
 
25
  @try
26
    {
27
      @throw object;
28
    }
29
  @catch (MyObject *o)
30
    {
31
      i += 1;
32
    }
33
  @catch (...)
34
    {
35
      i += 2;
36
    }
37
  @finally
38
    {
39
      i += 4;
40
    }
41
 
42
  return i;
43
}
44
 
45
int main (void)
46
{
47
  if (test ([MyObject new]) != 5)
48
    abort ();
49
 
50
  if (test ([TestsuiteObject new]) != 6)
51
    abort ();
52
 
53
  return 0;
54
}

powered by: WebSVN 2.1.0

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