Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / shadow.exp
CommitLineData
b811d2c2 1# Copyright 2008-2020 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
5b362f04 26if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
f5f3a911
TT
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
cdc7edd7 42gdb_test "print x" "= 33" "print class x shadowing global x"
8540c487
SW
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
cdc7edd7 52gdb_test "print x" "= 44" "print local x shadowing class x"
8540c487
SW
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
cdc7edd7 60gdb_test "print x" "= 55" "print inner scope x"
8540c487
SW
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
cdc7edd7 69gdb_test "print x" "= 55" "print local x not namespace x"
8540c487
SW
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
cdc7edd7 82gdb_test "print x" "= 11" "print imported namespace x"
This page took 1.804598 seconds and 4 git commands to generate.