xref: /openbsd-src/gnu/usr.bin/binutils/gdb/testsuite/gdb.cp/class2.cc (revision b725ae7711052a2233e31a66fefb8a752c388d7a)
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 
~A()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 
~B()38 B::~B()
39 {
40   a1 = 900;
41   b1 = 901;
42   b2 = 902;
43 }
44 
45 // Stop the compiler from optimizing away data.
refer(A *)46 void refer (A *)
47 {
48   ;
49 }
50 
51 struct empty {};
52 
53 // Stop the compiler from optimizing away data.
refer(empty *)54 void refer (empty *)
55 {
56   ;
57 }
58 
main(void)59 int main (void)
60 {
61   A alpha, *aap, *abp;
62   B beta, *bbp;
63   empty e;
64 
65   alpha.a1 = 100;
66   beta.a1 = 200; beta.b1 = 201; beta.b2 = 202;
67 
68   aap = α refer (aap);
69   abp = β  refer (abp);
70   bbp = β  refer (bbp);
71   refer (&e);
72 
73   return 0;  // marker return 0
74 } // marker close brace
75