aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/objc/execute/exceptions/throw-nil.m
blob: b6e7b8bb306975ae37e2a5e167d07bc3219831e1 (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-obj-c++-shared/TestsuiteObject.m"

#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 (TestsuiteObject *exc)
    {
      abort ();
    }
  @catch (id exc)
    {
      exception_catched = 1;
    }
  @finally
    {
      finally_called = 1;
    }


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

  return 0;
}

#endif