From a42952252f6cfaf3b84072997bd187c39b2088bb Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 2 Feb 2009 21:50:13 +0000 Subject: [PATCH] gdb PR exp/9059: * valops.c (find_overload_match): Follow typedefs before taking address of object argument. gdb/testsuite PR exp/9059: * gdb.cp/call-c.exp: Add regression test. * gdb.cp/call-c.cc (FooHandle): New typedef. (main): New variable 'handle'. --- gdb/ChangeLog | 6 ++++++ gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.cp/call-c.cc | 3 +++ gdb/testsuite/gdb.cp/call-c.exp | 3 +++ gdb/valops.c | 8 +++++--- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 416b3896812..53059c54edc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2009-02-02 Tom Tromey + + PR exp/9059: + * valops.c (find_overload_match): Follow typedefs before taking + address of object argument. + 2009-02-01 Doug Evans * target.h (target_waitstatus_to_string): Declare. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 3b3735c570a..55f2d0ee962 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2009-02-02 Tom Tromey + + PR exp/9059: + * gdb.cp/call-c.exp: Add regression test. + * gdb.cp/call-c.cc (FooHandle): New typedef. + (main): New variable 'handle'. + 2009-01-30 Vladimir Prus * lib/mi-support.exp (et_mi_thread_list) diff --git a/gdb/testsuite/gdb.cp/call-c.cc b/gdb/testsuite/gdb.cp/call-c.cc index 1c54b89a765..cc909932071 100644 --- a/gdb/testsuite/gdb.cp/call-c.cc +++ b/gdb/testsuite/gdb.cp/call-c.cc @@ -28,11 +28,14 @@ struct Foo { int x_; }; +typedef Foo *FooHandle; + int main() { Foo f; Foo *pf = &f; Foo* &rf = pf; + FooHandle handle = pf; rf->func(); /* set breakpoint here */ return func(0); } diff --git a/gdb/testsuite/gdb.cp/call-c.exp b/gdb/testsuite/gdb.cp/call-c.exp index cb3b9454acf..a80f4dde1ef 100644 --- a/gdb/testsuite/gdb.cp/call-c.exp +++ b/gdb/testsuite/gdb.cp/call-c.exp @@ -49,3 +49,6 @@ gdb_test "b [gdb_get_line_number {breakpoint here} ${testfile}.cc ]" \ gdb_test "print foo(1)" "\\\$$decimal = 1" gdb_test "continue" ".*breakpoint here.*" "continue to bp" gdb_test "print rf->func()" "\\\$$decimal = 1" + +# Regression test for method call via a typedef. +gdb_test "print handle->func()" "\\\$$decimal = 1" diff --git a/gdb/valops.c b/gdb/valops.c index 1c724d3a56c..09be6ddbb5b 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -2173,9 +2173,11 @@ find_overload_match (struct type **arg_types, int nargs, if (objp) { - if (TYPE_CODE (value_type (temp)) != TYPE_CODE_PTR - && (TYPE_CODE (value_type (*objp)) == TYPE_CODE_PTR - || TYPE_CODE (value_type (*objp)) == TYPE_CODE_REF)) + struct type *temp_type = check_typedef (value_type (temp)); + struct type *obj_type = check_typedef (value_type (*objp)); + if (TYPE_CODE (temp_type) != TYPE_CODE_PTR + && (TYPE_CODE (obj_type) == TYPE_CODE_PTR + || TYPE_CODE (obj_type) == TYPE_CODE_REF)) { temp = value_addr (temp); } -- 2.30.2