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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [g++.dg/] [eh/] [uncaught1.C] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
// PR libstdc++/10606
2
// { dg-do run }
3
 
4
#include 
5
#include 
6
 
7
 
8
struct Check {
9
  int obj1, obj2;
10
  bool state;
11
};
12
 
13
static Check const data[] = {
14
  { 0, 0, false },      // construct [0]
15
  { 1, 0, true  },      // [1] = [0]
16
  { 0, 0, true  },      // destruct [0]
17
  { 2, 1, true  },      // [2] = [1]
18
  { 2, 2, true  },      // destruct [2]
19
  { 3, 1, true  },      // [3] = [1]
20
  { 3, 3, false },      // destruct [3]
21
  { 1, 1, false },      // destruct [1]
22
  { 9, 9, false }       // end-of-data
23
};
24
 
25
static int pos = 0;
26
 
27
static void test(int obj1, int obj2, bool state)
28
{
29
  if (obj1 != data[pos].obj1) abort ();
30
  if (obj2 != data[pos].obj2) abort ();
31
  if (state != data[pos].state) abort ();
32
  pos++;
33
}
34
 
35
 
36
struct S {
37
  int id;
38
  S ();
39
  S (const S &);
40
  ~S ();
41
};
42
 
43
static int next_id = 0;
44
 
45
S::S()
46
  : id (next_id++)
47
{
48
  test (id, id, std::uncaught_exception ());
49
}
50
 
51
S::S(const S &x)
52
  : id (next_id++)
53
{
54
  test (id, x.id, std::uncaught_exception ());
55
}
56
 
57
S::~S()
58
{
59
  test (id, id, std::uncaught_exception ());
60
}
61
 
62
extern void foo (S *);
63
 
64
int main()
65
{
66
  try
67
    {
68
      try
69
        {
70
          S s0;
71
          throw s0;     // s1 is the exception object
72
        }
73
      catch (S s2)
74
        {
75
          throw;
76
        }
77
    }
78
  catch (S s3)
79
    {
80
    }
81
 
82
  return 0;
83
}

powered by: WebSVN 2.1.0

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