aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc/execute/exceptions/finally-1.m
blob: 30ec7b2d12a6b257d87ead37d0394ad00b13df42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <stdlib.h>
#include "../../../objc-obj-c++-shared/TestsuiteObject.m"

static int made_try = 0;

int
thrower_try_body()
{
  made_try++;
  return (0);
}

static int made_finally = 0;

int
finally_body()
{
  made_finally++;
  return (0);
}

int
thrower()
{
  @try
  {
    thrower_try_body();
    @throw [TestsuiteObject new];
  }
  @finally
  {
    finally_body();
  }     
  return 0;
}

static int made_catch = 0;

int 
main(int ac, char *av[])
{
  @try
  {
    thrower();
  }
  @catch (id exc)
  {
    made_catch++;
    [exc free];
  }
  if (made_try != 1)
    abort ();
  if (made_finally != 1)
    abort ();
  if (made_catch != 1)
    abort ();
  return 0;
}