| 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 |
int |
| 28 |
main (int argc, const char *argv[]) |
| 29 |
{ |
| 30 |
if (argc != 2) |
| 31 |
{ |
| 32 |
printf ("usage: a.out <num>\n"); |
| 33 |
exit (1); |
| 34 |
} |
| 35 |
int count = atoi (argv[1]); |
| 36 |
inc (count); |
| 37 |
printf ("success\n"); |
| 38 |
exit (0); |
| 39 |
} |