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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [exceptions-2.m] - Blame information for rev 713

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

Line No. Rev Author Line
1 704 jeremybenn
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2
/* { dg-do run } */
3
/* { dg-options "-fobjc-exceptions" } */
4
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5
 
6
/* This test checks the syntax @catch (...) which catches any
7
   exceptions.  Check that code using it runs correctly.  */
8
 
9
#include "../objc-obj-c++-shared/TestsuiteObject.m"
10
#include <stdlib.h>
11
 
12
@interface MyObject : TestsuiteObject
13
@end
14
 
15
@implementation MyObject
16
@end
17
 
18
int test (id object)
19
{
20
  int i = 0;
21
 
22
  @try
23
    {
24
      @throw object;
25
    }
26
  @catch (MyObject *o)
27
    {
28
      i += 1;
29
    }
30
  @catch (...)
31
    {
32
      i += 2;
33
    }
34
  @finally
35
    {
36
      i += 4;
37
    }
38
 
39
  return i;
40
}
41
 
42
int main (void)
43
{
44
  if (test ([MyObject new]) != 5)
45
    abort ();
46
 
47
  if (test ([TestsuiteObject new]) != 6)
48
    abort ();
49
 
50
  return 0;
51
}

powered by: WebSVN 2.1.0

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