aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/eh/dtor2.C
blob: 9555b3789af71b793ec63437f36dfa9e26c23cf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// PR c++/12751
// tree-ssa eh lowering bug ran a destructor twice for one object
// { dg-do run }

static int check;

struct Y {
  Y();
  ~Y();
};

void foo() {
  Y y1;
  Y y2;
  switch(0) {
    case 1: {
        Y y3;
        return;
      }
  }
}

Y::Y() { ++check; }
Y::~Y() { --check; }

int main()
{
  foo ();
  return check;
}