old-cross-binutils/gdb/testsuite/gdb.cp/smartp.exp
Siva Chandra 6c659fc2c7 Enable chained function calls in C++ expressions.
gdb/ChangeLog:

	* eval.c: Include gdbthread.h.
	(evaluate_subexp): Enable thread stack temporaries before
	evaluating a complete expression and clean them up after the
	evaluation is complete.
	* gdbthread.h: Include common/vec.h.
	(value_ptr): New typedef.
	(VEC (value_ptr)): New vector type.
	(value_vec): New typedef.
	(struct thread_info): Add new fields stack_temporaries_enabled
	and stack_temporaries.
	(enable_thread_stack_temporaries)
	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
	(get_last_thread_stack_temporary)
	(value_in_thread_stack_temporaries): Declare.
	* gdbtypes.c (class_or_union_p): New function.
	* gdbtypes.h (class_or_union_p): Declare.
	* infcall.c (call_function_by_hand): Store return values of class
	type as	temporaries on stack.
	* thread.c (enable_thread_stack_temporaries): New function.
	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
	(get_last_thread_stack_temporary): Likewise.
	(value_in_thread_stack_temporaries): Likewise.
	* value.c (value_force_lval): New function.
	* value.h (value_force_lval): Declare.

gdb/testsuite/ChangeLog:

	* gdb.cp/chained-calls.cc: New file.
	* gdb.cp/chained-calls.exp: New file.
	* gdb.cp/smartp.exp: Remove KFAIL for "p c2->inta".
2014-11-28 16:01:16 -08:00

76 lines
2.4 KiB
Text

# Copyright 2008-2014 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
standard_testfile .cc
if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
return -1
}
############################################
if ![runto_main] then {
perror "couldn't run to breakpoint main"
continue
}
gdb_breakpoint [gdb_get_line_number "end of main"]
gdb_continue_to_breakpoint "end of main"
# Test that overloaded arrow operator works
gdb_test "p mp->foo()" "= 11"
# Test that regular arrow operator still works
gdb_test "p mtp->foo()" "= 11"
# Test that normal '.' operator still works.
gdb_test "p mt1.foo()" "= 11"
# test that gdb extension '.' for pointers still works.
gdb_test "p mt4p.a" "= 11"
# test that gdb extension '->' for structs still works.
gdb_test "p mt4->a" "= 11"
# Test that templated smart pointers work
gdb_test "p sp1->foo()" "= 11"
gdb_test "p sp2->foo()" "= 22"
# Test that overload resolution works properly
# with smart pointers
gdb_test "p sp3->foo(1)" "= 33"
gdb_test "p sp3->foo('a')" "= 44"
# Test smart pointers work for member references
gdb_test "p sp4->a" "= 11"
gdb_test "p sp4->b" "= 12"
# Test regular arrow operator still works for
# member references
gdb_test "p mt4p->a" "= 11"
gdb_test "p mt4p->b" "= 12"
# Test that incorrect use of the arrow operator
# is still handled correctly.
gdb_test "p mt4->fake" "There is no member named fake."
gdb_test "p mt4->fake()" "Couldn't find method Type4::fake"
# Test that overloading of -> works recursively
gdb_test "p b->foo()" "= 66"
gdb_test "p c->foo()" "= 66"
gdb_test "p c->inta" "= 77"
gdb_test "p c2->inta" "= 77"