]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/shadow.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / shadow.exp
CommitLineData
618f726f 1# Copyright 2008-2016 Free Software Foundation, Inc.
8540c487
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
16# Test that when multiple variables have the same
17# name the one from the correct scope is printed.
18
8540c487 19
f5f3a911 20standard_testfile .cc
8540c487 21
4c93b1db 22if [get_compiler_info] {
1da644f0
SW
23 return -1
24}
25
f5f3a911
TT
26if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
27 return -1
28}
8540c487
SW
29
30if ![runto_main] then {
31 perror "couldn't run to breakpoint main"
32 continue
33}
34
35############################################
36# Test printing of class variable is not shadowed
37# by global variable
38
39gdb_breakpoint [gdb_get_line_number "marker1"]
40gdb_continue_to_breakpoint "marker1"
41
42gdb_test "print x" "= 33" "Print class x shadowing global x"
43
44
45############################################
46# Test printing local variable is not shadowed
47# by class variable
48
49gdb_breakpoint [gdb_get_line_number "marker2"]
50gdb_continue_to_breakpoint "marker2"
51
52gdb_test "print x" "= 44" "Print local x shadowing class x"
53
54############################################
55# Test inner scope x is printed not outer scope
56
57gdb_breakpoint [gdb_get_line_number "marker3"]
58gdb_continue_to_breakpoint "marker3"
59
60gdb_test "print x" "= 55" "Print inner scope x"
61
62############################################
63# Test printing local variable is not shadowed
64# by namespace variable
65
66gdb_breakpoint [gdb_get_line_number "marker4"]
67gdb_continue_to_breakpoint "marker4"
68
69gdb_test "print x" "= 55" "Print local x not namespace x"
70
71############################################
72# Test imported namespace element is printed
73
74gdb_breakpoint [gdb_get_line_number "marker5"]
75gdb_continue_to_breakpoint "marker5"
76
1da644f0
SW
77if { [test_compiler_info {gcc-[0-3]-*}] ||
78 [test_compiler_info {gcc-4-[0-3]-*}]} {
79 setup_xfail *-*-*
80}
81
8540c487 82gdb_test "print x" "= 11" "Print imported namespace x"