* gdb.mi/mi-var-cp.cc (reference_update_tests):
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-cp.cc
CommitLineData
6aba47ca 1/* Copyright 2006, 2007 Free Software Foundation, Inc.
b26ed50d
VP
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16*/
17
18void reference_update_tests ()
19{
2d0720d9 20 /*: BEGIN: reference_update :*/
b26ed50d 21 int x = 167;
2d0720d9 22 /*: mi_create_varobj "RX" "rx" "create varobj for rx" :*/
b26ed50d 23 int& rx = x;
2d0720d9
VP
24 /*: mi_varobj_update RX {RX} "update RX (1)"
25 mi_check_varobj_value RX 167 "check RX: expect 167"
26 :*/
b26ed50d 27 x = 567;
2d0720d9
VP
28 /*: mi_varobj_update RX {RX} "update RX (2)"
29 mi_check_varobj_value RX 567 "check RX: expect 567"
30 :*/
b26ed50d 31 x = 567;
2d0720d9
VP
32 /*: mi_varobj_update RX {} "update RX (3)"
33 :*/
81121995
VP
34 /* Dummy assignment to keep 'x' in scope. */
35 x = 444;
2d0720d9
VP
36
37 /*: END: reference_update :*/
b26ed50d
VP
38}
39
038224f6
VP
40struct S { int i; int j; };
41struct S2 : S {};
42
43int base_in_reference_test (S2& s2)
44{
2d0720d9 45 /*: BEGIN: base_in_reference :*/
038224f6 46 return s2.i;
2d0720d9
VP
47 /*:
48 mi_create_varobj "S2" "s2" "create varobj for s2"
49 mi_list_varobj_children "S2" {
50 {"S2.S" "S" "1" "S"}
51 } "list children of s2"
52 mi_list_varobj_children "S2.S" {
53 {"S2.S.public" "public" "2"}
54 } "list children of s2.s"
55 mi_list_varobj_children "S2.S.public" {
56 {"S2.S.public.i" "i" "0" "int"}
57 {"S2.S.public.j" "j" "0" "int"}
58 } "list children of s2.s.public"
59
60 mi_check_varobj_value "S2.S.public.i" "67" "check S2.S.public.i"
61 mi_check_varobj_value "S2.S.public.j" "89" "check S2.S.public.j"
62
63 :*/
64 /*: END: base_in_reference :*/
038224f6
VP
65}
66
67void base_in_reference_test_main ()
68{
69 S2 s;
70 s.i = 67;
71 s.j = 89;
72 base_in_reference_test (s);
73}
74
986d03be
NR
75int reference_to_pointer ()
76{
81121995 77 /*: BEGIN: reference_to_pointer :*/
986d03be
NR
78 S s, *ptr_s, *& rptr_s = ptr_s;
79 s.i = 67;
80 s.j = 89;
81 ptr_s = &s;
986d03be
NR
82 /*:
83 mi_create_varobj RPTR rptr_s "create varobj for rptr_s"
84
85 mi_list_varobj_children RPTR {{RPTR.public public 2}} \
86 "list public child of RPTR"
87
88 mi_list_varobj_children RPTR.public \
89 {{RPTR.public.i i 0 int}
90 {RPTR.public.j j 0 int}} "list children of reference to pointer"
91
92 mi_check_varobj_value RPTR.public.i 67 "check i member"
93 mi_check_varobj_value RPTR.public.j 89 "check j member"
94 :*/
81121995 95 return 99;
986d03be
NR
96 /*: END: reference_to_pointer :*/
97}
038224f6 98
b26ed50d
VP
99int main ()
100{
101 reference_update_tests ();
038224f6 102 base_in_reference_test_main ();
986d03be 103 reference_to_pointer ();
b26ed50d
VP
104 return 0;
105}
This page took 0.0378 seconds and 4 git commands to generate.