summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc/execute/exceptions/throw-nil.m
blob: cd9a797f5fd2cd19be364b181a3f0382c4fd98fc (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
#include <objc/objc.h>
#include <objc/Object.h>

#ifdef __NEXT_RUNTIME__
/* This test only runs for the GNU runtime.  */

int main(void)
{
  return 0;
}

#else

/* Test throwing a nil exception.  A 'nil' exception can only be
   caugth by a generic exception handler.
 */

int main (void)
{
  int exception_catched = 0;
  int finally_called = 0;

  @try
    {
      @throw nil;
    }
  @catch (Object *exc)
    {
      abort ();
    }
  @catch (id exc)
    {
      exception_catched = 1;
    }
  @finally
    {
      finally_called = 1;
    }


  if (exception_catched != 1
      || finally_called != 1)
    {
      abort ();
    }

  return 0;
}

#endif