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