Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / g++.old-deja / g++.eh / cleanup2.C
blob9538de961b70de895f72cac921ae44bc9897b17e
1 // { dg-do run  }
2 //  Copyright (C) 1999 Free Software Foundation, Inc.
3 //  Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org>
5 // make sure we don't call base dtors, if we failed to call the
6 // base ctor due to exception throwing
8 #include <stdio.h>
10 static bool bad = false;
12 static int thrower ()
14   printf ("in %s\n", __PRETTY_FUNCTION__);
15   throw 0;
16   return 0;
19 struct X
21   X (int) throw (int);
22   ~X () throw ();
25 X::X (int) throw (int)
26   {printf ("in ctor X %s\n", __PRETTY_FUNCTION__); bad = true;}
27 X::~X () throw ()
28   {printf ("in dtor X %s\n", __PRETTY_FUNCTION__); bad = true;}
30 struct X1 {};
31 struct Y : X
33   Y() throw (int);
34   ~Y() throw ();
36 Y::Y() throw (int)
37   : X(thrower ())   // throws, so X::X is never called
38   {printf ("in ctor Y%s\n", __PRETTY_FUNCTION__); bad = true;}
39 Y::~Y() throw ()
40   {printf ("in dtor Y%s\n", __PRETTY_FUNCTION__); bad = true;}
42 int main ()
44   try
45     {
46       Y y;
47     }
48   catch (...)
49     {
50       printf ("caught\n");
51     }
52   return bad;