2004-02-11 Michael Chastain <mec.gnu@mindspring.com>
[binutils-gdb.git] / gdb / testsuite / gdb.cp / class2.cc
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2003, 2004 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 struct A
21 {
22 virtual ~A ();
23 int a1;
24 };
25
26 A::~A()
27 {
28 a1 = 800;
29 }
30
31 struct B : public A
32 {
33 virtual ~B ();
34 int b1;
35 int b2;
36 };
37
38 B::~B()
39 {
40 a1 = 900;
41 b1 = 901;
42 b2 = 902;
43 }
44
45 // Stop the compiler from optimizing away data.
46 void refer (A *)
47 {
48 ;
49 }
50
51 int main (void)
52 {
53 A alpha, *aap, *abp;
54 B beta, *bbp;
55
56 alpha.a1 = 100;
57 beta.a1 = 200; beta.b1 = 201; beta.b2 = 202;
58
59 aap = &alpha; refer (aap);
60 abp = &beta; refer (abp);
61 bbp = &beta; refer (bbp);
62
63 return 0; // marker return 0
64 } // marker close brace