OSDN Git Service

Copyright updates for 2007.
[pf3gnuchains/pf3gnuchains3x.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 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
18 void reference_update_tests ()
19 {
20   /*: BEGIN: reference_update :*/
21   int x = 167;
22   /*: mi_create_varobj "RX" "rx" "create varobj for rx" :*/
23   int& rx = x;
24   /*: mi_varobj_update RX {RX} "update RX (1)"
25       mi_check_varobj_value RX 167 "check RX: expect 167"
26       :*/
27   x = 567;
28   /*: mi_varobj_update RX {RX} "update RX (2)"
29       mi_check_varobj_value RX 567 "check RX: expect 567"
30       :*/  
31   x = 567;
32   /*: mi_varobj_update RX {} "update RX (3)"
33     :*/
34
35   /*: END: reference_update :*/
36 }
37
38 struct S { int i; int j; };
39 struct S2 : S {};
40         
41 int base_in_reference_test (S2& s2)
42 {
43   /*: BEGIN: base_in_reference :*/
44   return s2.i;
45   /*: 
46     mi_create_varobj "S2" "s2" "create varobj for s2"
47     mi_list_varobj_children "S2" {
48        {"S2.S" "S" "1" "S"}
49     } "list children of s2"
50     mi_list_varobj_children "S2.S" {
51        {"S2.S.public" "public" "2"}
52     } "list children of s2.s"
53     mi_list_varobj_children "S2.S.public" {
54        {"S2.S.public.i" "i" "0" "int"}
55        {"S2.S.public.j" "j" "0" "int"}
56     } "list children of s2.s.public"
57
58     mi_check_varobj_value "S2.S.public.i" "67" "check S2.S.public.i"
59     mi_check_varobj_value "S2.S.public.j" "89" "check S2.S.public.j"
60
61   :*/
62   /*: END: base_in_reference :*/
63 }
64         
65 void base_in_reference_test_main ()
66 {
67   S2 s;
68   s.i = 67;
69   s.j = 89;
70   base_in_reference_test (s);
71 }
72
73 int reference_to_pointer ()
74 {
75   S s, *ptr_s, *& rptr_s = ptr_s;
76   s.i = 67;
77   s.j = 89;
78   ptr_s = &s;
79   /*: BEGIN: reference_to_pointer :*/
80   return 99;
81   /*: 
82     mi_create_varobj RPTR rptr_s "create varobj for rptr_s"
83
84     mi_list_varobj_children RPTR {{RPTR.public public 2}}       \
85     "list public child of RPTR"
86
87     mi_list_varobj_children  RPTR.public        \
88     {{RPTR.public.i i 0 int}
89     {RPTR.public.j j 0 int}} "list children of reference to pointer"
90
91     mi_check_varobj_value RPTR.public.i 67 "check i member"
92     mi_check_varobj_value RPTR.public.j 89 "check j member"
93   :*/
94   /*: END: reference_to_pointer :*/
95 }
96
97 int main ()
98 {
99   reference_update_tests ();
100   base_in_reference_test_main ();
101   reference_to_pointer ();
102   return 0;
103 }