Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / virtbase2.exp
CommitLineData
b811d2c2 1# Copyright 2018-2020 Free Software Foundation, Inc.
9f6b697b
WP
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# Make sure printing virtual base class data member works correctly (PR16841)
17
18if { [skip_cplus_tests] } { continue }
19
20standard_testfile .cc
21
22if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
23 return -1
24}
25
26if {![runto_main]} then {
27 perror "couldn't run to main"
28 continue
29}
30
31# From a list of nested scopes, generate all possible ways of accessing something
32# in those scopes. For example, with the argument {foo bar baz}, this proc will
33# return:
34# - {} (empty string)
35# - baz::
36# - bar::
37# - bar::baz::
38# - foo::
39# - foo::baz::
40# - foo::bar::
41# - foo::bar::baz::
42
43proc make_scope_list { scopes } {
44 if { [llength $scopes] == 1 } {
45 return [list "" "${scopes}::"]
46 }
47
48 # Pop the first element, save the first scope.
49 set this_scope [lindex $scopes 0]
50 set scopes [lreplace $scopes 0 0]
51
52 set child_result [make_scope_list $scopes]
53
54 # Add a copy of the child's result without this scope...
55 set result $child_result
56
57 # ... and a copy of the child's result with this scope.
58 foreach r $child_result {
59 lappend result "${this_scope}::$r"
60 }
61
62 return $result
63}
64
65proc test_variables_in_base { scopes } {
66 foreach scope [make_scope_list $scopes] {
67 gdb_test "print ${scope}i" " = 55"
68 gdb_test "print ${scope}d" " = 6.25"
69 gdb_test "print ${scope}x" " = 22"
70 }
71}
72
73proc test_variables_in_superbase { scopes } {
74 foreach scope [make_scope_list $scopes] {
75 gdb_test "print ${scope}x" " = 22"
76 }
77}
78
79proc test_variables_in_super { scopes } {
80 foreach scope [make_scope_list $scopes] {
81 gdb_test "print ${scope}w" " = 17"
82 }
83}
84
85with_test_prefix "derived::func_d" {
86 gdb_breakpoint "derived::func_d"
87 gdb_continue_to_breakpoint "continue to derived::func_d"
88 test_variables_in_base {derived base}
89 test_variables_in_superbase {derived base superbase}
90 test_variables_in_superbase {base superbase}
91 test_variables_in_superbase {derived superbase}
92 test_variables_in_superbase {superbase}
93 test_variables_in_superbase {base}
94 test_variables_in_super {super}
95 test_variables_in_super {derived super}
96}
97
98with_test_prefix "foo::func_f" {
99 gdb_breakpoint "foo::func_f"
100 gdb_continue_to_breakpoint "continue to foo::func_f"
101 test_variables_in_base {foo derived base}
102 test_variables_in_base {foo base}
103 test_variables_in_base {base}
104 test_variables_in_superbase {superbase}
105 test_variables_in_superbase {foo superbase}
106 test_variables_in_superbase {foo derived superbase}
107 test_variables_in_superbase {foo derived base superbase}
108 test_variables_in_super {super}
109 test_variables_in_super {foo super}
110 test_variables_in_super {foo derived super}
111}
This page took 0.176913 seconds and 4 git commands to generate.