Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / call-method-register.exp
CommitLineData
88b9d363 1# Copyright 1992-2022 Free Software Foundation, Inc.
d5f96005
PA
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 callling a method on a variable that has been put in a
17# register.
18
19if { [skip_cplus_tests] } { continue }
20
21load_lib "cp-support.exp"
22
23standard_testfile .cc
24
25if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
26 return -1
27}
28
29proc test_call_register_class {} {
30 global gdb_prompt
31
32 if ![runto_main] {
33 fail "couldn't run to main"
34 return
35 }
36
37 set bp_location [gdb_get_line_number "set breakpoint here"]
38 gdb_breakpoint $bp_location
39 gdb_continue_to_breakpoint "break here"
40
41 # This class is so small that an instance of it can fit in a register.
42 # When gdb tries to call a method, it gets embarrassed about taking
43 # the address of a register.
44 #
45 # That message is a PASS, not an XFAIL, because gdb prints an
46 # informative message and declines to do something impossible.
47 #
48 # The method call actually succeeds if the compiler allocates very
49 # small classes in memory instead of registers. If that happens,
50 # it's a FAIL, because the testcase is written in a form such that
51 # it should not happen.
52 gdb_test "print v.method ()" \
53 "Address requested for identifier \"v\" which is in register .*" \
54 "call method on register local"
55}
56
57test_call_register_class
This page took 0.146861 seconds and 4 git commands to generate.