This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFA: fix PR 9059
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 19 Dec 2008 16:48:20 -0700
- Subject: RFA: fix PR 9059
- Reply-to: Tom Tromey <tromey at redhat dot com>
This patch fixes PR 9059.
The bug is that a method call on an object whose declared type is a
typedef will not work properly. The fix is to call check_typedef
before deciding how to handle the "this" pointer.
Built and regtested on x86-64 (compile farm).
New test case included.
Please review.
thanks,
Tom
2008-12-19 Tom Tromey <tromey@redhat.com>
PR exp/9059:
* valops.c (find_overload_match): Follow typedefs before taking
address of object argument.
2008-12-19 Tom Tromey <tromey@redhat.com>
PR exp/9059:
* gdb.cp/call-c.exp: Add regression test.
* gdb.cp/call-c.cc (FooHandle): New typedef.
(main): New variable 'handle'.
diff --git a/gdb/testsuite/gdb.cp/call-c.cc b/gdb/testsuite/gdb.cp/call-c.cc
index 8ab617e..384404b 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 494d48f..e108fd8 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 05e5351..d242ed1 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2124,9 +2124,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);
}