2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / eh1.C
blob8105107f363a5ef96ede67fe840826ca3d634963
1 // { dg-do assemble  }
2 // { dg-options "-fexceptions -O -S" }
4 extern "C" int printf (const char *, ...);
5 extern "C" int atoi (const char *);
6 extern "C" void exit (int);
8 struct Exception
9  {
10      int v;
11      Exception(int i) { v = i; };
12  };
14  void inc(int &i)
15  {
16      try {
17          if (i == 0)
18              throw Exception(i);
19          else
20              i++;
21      }
22      catch (Exception v) {
23          i = v.v;
24      }
25  }
27 main (int argc, const char *argv[])
29   if (argc != 2)
30     {
31       printf ("usage: a.out <num>\n");
32       exit (1);
33     }
34   int count = atoi (argv[1]);
35   inc (count);
36   printf ("success\n");
37   exit (0);