gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / ref-params.cc
CommitLineData
fb933624
DJ
1/* This test script is part of GDB, the GNU debugger.
2
3 Copyright 2006
4 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21/* Author: Paul N. Hilfinger, AdaCore Inc. */
22
23struct Parent {
24 Parent (int id0) : id(id0) { }
25 int id;
26};
27
28struct Child : public Parent {
29 Child (int id0) : Parent(id0) { }
30};
31
32int f1(Parent& R)
33{
34 return R.id; /* Set breakpoint marker3 here. */
35}
36
37int f2(Child& C)
38{
39 return f1(C); /* Set breakpoint marker2 here. */
40}
41
42struct OtherParent {
43 OtherParent (int other_id0) : other_id(other_id0) { }
44 int other_id;
45};
46
47struct MultiChild : public Parent, OtherParent {
48 MultiChild (int id0) : Parent(id0), OtherParent(id0 * 2) { }
49};
50
51int mf1(OtherParent& R)
52{
53 return R.other_id;
54}
55
56int mf2(MultiChild& C)
57{
58 return mf1(C);
59}
60
61int main(void)
62{
63 Child Q(42);
64 Child& QR = Q;
65
66 #ifdef usestubs
67 set_debug_traps();
68 breakpoint();
69 #endif
70
71 /* Set breakpoint marker1 here. */
72
73 f2(Q);
74 f2(QR);
75
76 MultiChild MQ(53);
77 MultiChild& MQR = MQ;
78
79 mf2(MQ); /* Set breakpoint MQ here. */
80}
This page took 0.029387 seconds and 4 git commands to generate.