Automatic date update in version.in
[binutils-gdb/blckswan.git] / gdb / testsuite / gdb.cp / method-call-in-c.exp
blobbf2032a7cc172b9fbb51ca13e13d53552de9aa28
1 # Copyright 2021-2022 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Ensure that calling a member function works correctly even when the
17 # language is forced to 'C' (this should be fine, so long at no
18 # overload resolution is required), or when overload-resolution is
19 # off.
21 standard_testfile .cc
23 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
24 return -1
27 if ![runto_main] then {
28 return 0
31 gdb_breakpoint [gdb_get_line_number "Break here"]
32 gdb_continue_to_breakpoint "Break here"
34 set result 123
35 foreach_with_prefix lang { c++ c } {
36 foreach_with_prefix overload_resolution { on off } {
37 gdb_test_no_output "set overload-resolution ${overload_resolution}"
38 gdb_test "set language ${lang}"
40 gdb_test "print foo.func (b, f)" " = ${result}"
41 incr result
43 set result [expr $result + 3]
44 gdb_test "print foo += b" \
45 " = \\((?:struct )?foo_type &\\) @${hex}: \\\{var = ${result}\\\}"
47 gdb_test "print foo.static_method (f, b)" " = 4"
48 gdb_test "print foo_type::static_method (f, b)" " = 4"