* lib/gdb.exp (skip_altivec_tests, skip_vsx_tests)
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / nsusing.exp
1 # Copyright 2008, 2010-2012 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 set testfile nsusing
18 set srcfile ${testfile}.cc
19 set binfile ${objdir}/${subdir}/${testfile}
20 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
21 {debug c++}] != "" } {
22 untested "Couldn't compile test program"
23 return -1
24 }
25
26 if [get_compiler_info] {
27 return -1
28 }
29
30
31 # Get things started.
32
33 gdb_exit
34 gdb_start
35 gdb_reinitialize_dir $srcdir/$subdir
36 gdb_load ${binfile}
37
38 ############################################
39 # test printing of namespace imported within
40 # the function.
41
42 if ![runto_main] then {
43 perror "couldn't run to breakpoint main"
44 continue
45 }
46
47 gdb_test "print _a" "= 1"
48
49 # Test that names are not printed when they
50 # are not imported
51
52 gdb_breakpoint marker3
53 gdb_continue_to_breakpoint "marker3"
54
55 #send_gdb "break marker3\n"
56 #send_gdb "continue\n"
57
58 gdb_test "print _a" "No symbol \"_a\" in current context." \
59 "Print _a without import"
60
61 gdb_exit
62 gdb_start
63 gdb_reinitialize_dir $srcdir/$subdir
64 gdb_load ${binfile}
65
66
67 ############################################
68 # test printing of namespace imported into
69 # a scope containing the pc.
70
71 if ![runto_main] then {
72 perror "couldn't run to breakpoint main"
73 continue
74 }
75
76 gdb_breakpoint [gdb_get_line_number "marker1 stop"]
77 gdb_continue_to_breakpoint "marker1 stop"
78
79 gdb_test "print _a" "= 1" "print _a in a nested scope"
80
81
82 gdb_exit
83 gdb_start
84 gdb_reinitialize_dir $srcdir/$subdir
85 gdb_load ${binfile}
86
87 ############################################
88 # test printing of namespace imported into
89 # file scope.
90
91
92 if ![runto marker5] then {
93 perror "couldn't run to breakpoint marker5"
94 continue
95 }
96
97 gdb_test "print cc" "= 3"
98
99 gdb_exit
100 gdb_start
101 gdb_reinitialize_dir $srcdir/$subdir
102 gdb_load ${binfile}
103
104
105 ############################################
106 # Test printing of namespace aliases
107
108 if ![runto marker2] then {
109 perror "couldn't run to breakpoint marker2"
110 continue
111 }
112
113 gdb_test "print B::_a" "= 1"
114
115 gdb_test "print _a" "No symbol \"_a\" in current context." \
116 "print _a in namespace alias scope"
117
118 gdb_test "print x" "No symbol \"x\" in current context." \
119 "print x in namespace alias scope"
120
121 gdb_exit
122 gdb_start
123 gdb_reinitialize_dir $srcdir/$subdir
124 gdb_load ${binfile}
125
126
127 ############################################
128 # Test that names are not printed when they
129 # are not imported
130
131 if {![runto marker3]} {
132 perror "couldn't run to breakpoint marker3"
133 }
134
135 # gcc-4-3 puts import statements for aliases in
136 # the global scope instead of the corresponding
137 # function scope. These wrong import statements throw
138 # this test off. This is fixed in gcc-4-4.
139 if [test_compiler_info gcc-4-3-*] then { setup_xfail *-*-* }
140
141 gdb_test "print _a" "No symbol \"_a\" in current context." \
142 "Print _a without import"
143
144 ############################################
145 # Test printing of individually imported elements
146
147 if ![runto marker4] then {
148 perror "couldn't run to breakpoint marker4"
149 continue
150 }
151
152 gdb_test "print dx" "= 4"
153
154 ############################################
155 # Test printing of namespace aliases
156
157 if ![runto marker5] then {
158 perror "couldn't run to marker5"
159 continue
160 }
161
162 gdb_test "print efx" "= 5"
163
164 ############################################
165 # Test printing of variables imported from
166 # nested namespaces
167
168 if ![runto I::marker7] then {
169 perror "couldn't run to breakpoint I::marker7"
170 continue
171 }
172
173 gdb_test "print ghx" "= 6"
174
175 ############################################
176 # Test that variables are not printed in a namespace
177 # that is sibling to the namespace containing an import
178
179 if ![runto L::marker8] then {
180 perror "couldn't run to breakpoint L::marker8"
181 continue
182 }
183
184 gdb_test "print jx" "= 44"
185
186 gdb_breakpoint "K::marker9"
187 gdb_continue_to_breakpoint "K::marker9"
188
189 gdb_test "print jx" "No symbol \"jx\" in current context."
190
191 ############################################
192 # Test that variables are only printed after the line
193 # containing the import
194
195 if ![runto_main] then {
196 perror "couldn't run to breakpoint main"
197 continue
198 }
199
200 gdb_breakpoint [gdb_get_line_number "marker10 stop"]
201 gdb_continue_to_breakpoint "marker10 stop"
202
203 if { [test_compiler_info {gcc-[0-3]-*}] ||
204 [test_compiler_info {gcc-4-[0-3]-*}]} {
205 setup_xfail *-*-*
206 }
207
208 # Assert that M::x is printed and not N::x
209 gdb_test "print x" "= 911" "print x (from M::x)"
This page took 0.040824 seconds and 5 git commands to generate.