blob: f3c666e5d8ece11fc9c00d89406754e333d70092 [file] [log] [blame]
# Copyright 1992-2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>.
# Test callling a method on a variable that has been put in a
# register.
if { [skip_cplus_tests] } { continue }
load_lib "cp-support.exp"
standard_testfile .cc
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
return -1
proc test_call_register_class {} {
global gdb_prompt
if ![runto_main] {
set bp_location [gdb_get_line_number "set breakpoint here"]
gdb_breakpoint $bp_location
gdb_continue_to_breakpoint "break here"
# This class is so small that an instance of it can fit in a register.
# When gdb tries to call a method, it gets embarrassed about taking
# the address of a register.
# That message is a PASS, not an XFAIL, because gdb prints an
# informative message and declines to do something impossible.
# The method call actually succeeds if the compiler allocates very
# small classes in memory instead of registers. If that happens,
# it's a FAIL, because the testcase is written in a form such that
# it should not happen.
gdb_test "print v.method ()" \
"Address requested for identifier \"v\" which is in register .*" \
"call method on register local"