Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / g++.dg / eh / scope1.C
blob276e0d6e588e8badb4aff5b9f137347adc05ddb9
1 // Test that we've scoped the destructor properly for variables declared
2 // in a conditional.
3 // { dg-do run }
5 extern "C" void abort ();
7 class C
9   bool live;
10  public:
11   C();
12   C(const C &);
13   ~C ();
14   operator bool() const;
17 void f1 ()
19   while (C br = C()) abort ();
22 void f2 ()
24   for (; C br = C(); ) abort ();
27 void f3 ()
29   if (C br = C()) abort ();
32 void f4 ()
34   switch (C br = C())
35     {
36     default:
37       abort ();
38     case false:
39       break;
40     }
43 int main()
45   f1(); f2(); f3(); f4();
46   return 0;
49 C::C()
51   live = true;
54 C::C(const C &o)
56   if (!o.live)
57     abort ();
58   live = true;
61 C::~C()
63   live = false;
66 C::operator bool() const
68   if (!live)
69     abort ();
70   return false;