]>
Commit | Line | Data |
---|---|---|
58da2eb2 DC |
1 | /* Code to go along with tests in rtti.exp. |
2 | ||
7b6bb8da JB |
3 | Copyright 2003, 2004, 2007, 2008, 2009, 2010, 2011 |
4 | Free Software Foundation, Inc. | |
58da2eb2 DC |
5 | |
6 | Contributed by David Carlton <carlton@bactrian.org> and by Kealia, | |
7 | Inc. | |
8 | ||
9 | This file is part of GDB. | |
10 | ||
11 | This program is free software; you can redistribute it and/or modify | |
12 | it under the terms of the GNU General Public License as published by | |
a9762ec7 JB |
13 | the Free Software Foundation; either version 3 of the License, or |
14 | (at your option) any later version. | |
58da2eb2 | 15 | |
a9762ec7 JB |
16 | This program is distributed in the hope that it will be useful, |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | GNU General Public License for more details. | |
58da2eb2 DC |
20 | |
21 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 22 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
58da2eb2 DC |
23 | |
24 | #include "rtti.h" | |
25 | ||
26 | namespace n1 { | |
27 | ||
28 | class C1; | |
29 | ||
30 | class Base1 { | |
31 | public: | |
32 | virtual ~Base1() { } | |
33 | }; | |
34 | ||
35 | ||
36 | class C1: public Base1 { | |
37 | public: | |
38 | }; | |
39 | ||
40 | class D1 : public C1{ | |
41 | public: | |
42 | D1(C1 *, C1 *); | |
43 | ||
44 | C1* expr_1_; | |
45 | C1* expr_2_; | |
46 | }; | |
47 | ||
48 | D1::D1(C1 *expr_1, C1 *expr_2) | |
49 | : expr_1_(expr_1), expr_2_(expr_2) { } | |
50 | ||
51 | C1 *create1() { | |
52 | return new D1(0, 0); | |
53 | } | |
54 | ||
55 | } // n1 | |
56 | ||
b368761e DC |
57 | // NOTE: carlton/2004-01-23: This call exists only to convince GCC to |
58 | // keep around a reference to 'obj' in n2::func - GCC 3.4 had been | |
59 | // optimizing it away. | |
60 | void refer_to (n2::C2 *obj) | |
61 | { | |
62 | // Do nothing. | |
63 | } | |
64 | ||
1198ecbe DC |
65 | void refer_to (n2::n3::C3 *obj) |
66 | { | |
67 | // Do nothing. | |
68 | } | |
69 | ||
b368761e DC |
70 | namespace n2 |
71 | { | |
72 | void func () | |
73 | { | |
74 | C2 *obj = create2 (); | |
75 | ||
1198ecbe | 76 | refer_to (obj); // func-constructs-done |
b368761e DC |
77 | |
78 | return; | |
79 | } | |
1198ecbe DC |
80 | |
81 | namespace n3 | |
82 | { | |
83 | void func3 () | |
84 | { | |
85 | C3 *obj3 = create3 (); | |
86 | ||
87 | refer_to (obj3); // func3-constructs-done | |
88 | ||
89 | return; | |
90 | } | |
91 | } | |
b368761e DC |
92 | } |
93 | ||
58da2eb2 DC |
94 | int main() |
95 | { | |
96 | using namespace n1; | |
97 | using namespace n2; | |
98 | ||
99 | C1 *e1 = create1(); | |
100 | C2 *e2 = create2(); | |
101 | ||
b368761e | 102 | n2::func(); // main-constructs-done |
1198ecbe | 103 | n2::n3::func3(); |
b368761e DC |
104 | |
105 | return 0; | |
58da2eb2 | 106 | } |