OSDN Git Service

Index: cp/ChangeLog
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.mike / eh1.C
1 // { dg-do assemble  }
2 // { dg-options "-fexceptions -O -S" }
3
4 extern "C" int printf (const char *, ...);
5 extern "C" int atoi (const char *);
6 extern "C" void exit (int);
7
8 struct Exception
9  {
10      int v;
11      Exception(int i) { v = i; };
12  };
13
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  }
26
27 main (int argc, const char *argv[])
28 {
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);
38 }