OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.hp/] [gdb.aCC/] [exception.cc] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
// Test file for exception handling support.
2
 
3
#include <iostream.h>
4
 
5
int foo (int i)
6
{
7
  if (i < 32)
8
    throw (int) 13;
9
  else
10
    return i * 2;
11
}
12
 
13
extern "C" int bar (int k, unsigned long eharg, int flag);
14
 
15
int bar (int k, unsigned long eharg, int flag)
16
{
17
  cout << "k is " << k << " eharg is " << eharg << " flag is " << flag << endl;
18
  return 1;
19
}
20
 
21
int main()
22
{
23
  int j;
24
 
25
  try {
26
    j = foo (20);
27
  }
28
  catch (int x) {
29
    cout << "Got an except " << x << endl;
30
  }
31
 
32
  try {
33
    try {
34
      j = foo (20);
35
    }
36
    catch (int x) {
37
      cout << "Got an except " << x << endl;
38
      throw;
39
    }
40
  }
41
  catch (int y) {
42
    cout << "Got an except (rethrown) " << y << endl;
43
  }
44
 
45
  // Not caught 
46
  foo (20);
47
 
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.