Switch the license of all .c files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-cp.cc
1 /* Copyright 2006, 2007 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
15 */
16
17 void reference_update_tests ()
18 {
19 /*: BEGIN: reference_update :*/
20 int x = 167;
21 /*: mi_create_varobj "RX" "rx" "create varobj for rx" :*/
22 int& rx = x;
23 /*: mi_varobj_update RX {RX} "update RX (1)"
24 mi_check_varobj_value RX 167 "check RX: expect 167"
25 :*/
26 x = 567;
27 /*: mi_varobj_update RX {RX} "update RX (2)"
28 mi_check_varobj_value RX 567 "check RX: expect 567"
29 :*/
30 x = 567;
31 /*: mi_varobj_update RX {} "update RX (3)"
32 mi_delete_varobj RX "delete RX"
33 :*/
34 /* Dummy assignment to keep 'x' in scope. */
35 x = 444;
36
37 /*: END: reference_update :*/
38 }
39
40 struct S { int i; int j; };
41 struct S2 : S {};
42
43 int base_in_reference_test (S2& s2)
44 {
45 /*: BEGIN: base_in_reference :*/
46 return s2.i;
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 mi_delete_varobj S2 "delete S2"
63
64 :*/
65 /*: END: base_in_reference :*/
66 }
67
68 void base_in_reference_test_main ()
69 {
70 S2 s;
71 s.i = 67;
72 s.j = 89;
73 base_in_reference_test (s);
74 }
75
76 int reference_to_pointer ()
77 {
78 /*: BEGIN: reference_to_pointer :*/
79 S s, *ptr_s, *& rptr_s = ptr_s;
80 s.i = 67;
81 s.j = 89;
82 ptr_s = &s;
83 /*:
84 mi_create_varobj RPTR rptr_s "create varobj for rptr_s"
85
86 mi_list_varobj_children RPTR {{RPTR.public public 2}} \
87 "list public child of RPTR"
88
89 mi_list_varobj_children RPTR.public \
90 {{RPTR.public.i i 0 int}
91 {RPTR.public.j j 0 int}} "list children of reference to pointer"
92
93 mi_check_varobj_value RPTR.public.i 67 "check i member"
94 mi_check_varobj_value RPTR.public.j 89 "check j member"
95 mi_delete_varobj RPTR "delete RPTR"
96 :*/
97 return 99;
98 /*: END: reference_to_pointer :*/
99 }
100
101 int reference_to_struct ()
102 {
103 /*: BEGIN: reference_to_struct :*/
104 S s = {7, 8};
105 S& r = s;
106 /*:
107 mi_create_varobj S s "create varobj for s"
108 mi_create_varobj R r "create varobj for s"
109 mi_gdb_test "-var-show-attributes S" \
110 "\\^done,attr=\"noneditable\"" \
111 "check attributes of S"
112 mi_gdb_test "-var-show-attributes R" \
113 "\\^done,attr=\"noneditable\"" \
114 "check attributes of R"
115 :*/
116 s.i = 56;
117 /*: mi_varobj_update * [] "-var-update should not list structure varobjs"
118 :*/
119 return 99;
120 /*: END: reference_to_struct :*/
121 }
122
123 int main ()
124 {
125 reference_update_tests ();
126 base_in_reference_test_main ();
127 reference_to_pointer ();
128 reference_to_struct ();
129 return 0;
130 }
This page took 0.082555 seconds and 5 git commands to generate.