aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/eh/ctor1.C
blob: b959d1c5620878108ebb20e86bff645bf3ce5ea3 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// { dg-do run }

// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com>

// PR 411

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#define NOEXCEPT_FALSE noexcept (false)
#else
#define NOEXCEPT_FALSE
#endif

bool was_f_in_Bar_destroyed=false;

struct Foo
{
  ~Foo()
  {
    was_f_in_Bar_destroyed=true;
  }
};

struct Bar
{
  ~Bar() NOEXCEPT_FALSE
  {
    throw 1;
  }
  
  Foo f;
};

int main()
{
  try
    {
      Bar f; 
    }
  catch(int i)
    {
      if(was_f_in_Bar_destroyed)
	{
	  return 0;
	}
    }
  return 1;
}