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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc.dg/] [try-catch-1.m] - Blame information for rev 325

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

Line No. Rev Author Line
1 309 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-obj-c++-shared/Object1.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.