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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc.dg/] [try-catch-1.m] - Blame information for rev 867

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

Line No. Rev Author Line
1 149 jeremybenn
/* Test if the compiler accepts @throw / @try..@catch..@finally syntax.  */
2
/* Developed by Ziemowit Laski <zlaski@apple.com>.  */
3
/* { dg-options "-fobjc-exceptions" } */
4
/* { dg-do compile } */
5
 
6
#include <objc/Object.h>
7
#include <stdio.h>
8
#include <setjmp.h>
9
 
10
@interface Frob: Object
11
@end
12
 
13
@implementation Frob: Object
14
@end
15
 
16
static int exc_control = 0;
17
 
18
int proc() {
19
  if(exc_control) {
20
    printf ("Throwing (%d)... ", exc_control);
21
    @throw [Frob new];
22
  }
23
  return 1;
24
}
25
 
26
int foo()
27
{
28
        @try {
29
                return proc();
30
        }
31
        @catch (Frob* ex) {
32
                if(exc_control > 1) {
33
                  printf("Rethrowing (%d)... ", exc_control);
34
                  @throw;
35
                }
36
                return 0;
37
        }
38
        @finally {
39
                printf("In @finally block (%d)... ", exc_control);
40
        }
41
}

powered by: WebSVN 2.1.0

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