Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.eh/cleanup2.C

raw
1 // { dg-do run }
2 // Copyright (C) 1999 Free Software Foundation, Inc.
3 // Contributed by Nathan Sidwell 21 Nov 1999 <[email protected]>
4
5 // make sure we don't call base dtors, if we failed to call the
6 // base ctor due to exception throwing
7
8 #include <stdio.h>
9
10 static bool bad = false;
11
12 static int thrower ()
13 {
14 printf ("in %s\n", __PRETTY_FUNCTION__);
15 throw 0;
16 return 0;
17 }
18
19 struct X
20 {
21 X (int)
22 #if __cplusplus <= 201402L
23 throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } }
24 #endif
25 ;
26 ~X () throw ();
27 };
28
29 X::X (int)
30 #if __cplusplus <= 201402L
31 throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } }
32 #endif
33 {printf ("in ctor X %s\n", __PRETTY_FUNCTION__); bad = true;}
34 X::~X () throw ()
35 {printf ("in dtor X %s\n", __PRETTY_FUNCTION__); bad = true;}
36
37 struct X1 {};
38 struct Y : X
39 {
40 Y()
41 #if __cplusplus <= 201402L
42 throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } }
43 #endif
44 ;
45 ~Y() throw ();
46 };
47 Y::Y()
48 #if __cplusplus <= 201402L
49 throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } }
50 #endif
51 : X(thrower ()) // throws, so X::X is never called
52 {printf ("in ctor Y%s\n", __PRETTY_FUNCTION__); bad = true;}
53 Y::~Y() throw ()
54 {printf ("in dtor Y%s\n", __PRETTY_FUNCTION__); bad = true;}
55
56 int main ()
57 {
58 try
59 {
60 Y y;
61 }
62 catch (...)
63 {
64 printf ("caught\n");
65 }
66 return bad;
67 }