aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-03-15 17:10:45 +0000
committerTom Tromey <tromey@redhat.com>2013-03-15 17:10:45 +0000
commit9ce986499ee815d3adf734463ee6d7eda61a1c2f (patch)
tree855db92dd2448cd7285abad9466208ba9a5c826f /gdb
parentfc7b0af761918cc0ca6806841dbec6f78aca4077 (diff)
downloadgdb-9ce986499ee815d3adf734463ee6d7eda61a1c2f.zip
gdb-9ce986499ee815d3adf734463ee6d7eda61a1c2f.tar.gz
gdb-9ce986499ee815d3adf734463ee6d7eda61a1c2f.tar.bz2
PR c++/15116:
* gdbtypes.c (types_equal): Handle TYPE_CODE_FUNC. gdb/testsuite * gdb.cp/overload.cc (intintfunc): New. * gdb.cp/overload.exp: Add regression test.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/gdbtypes.c19
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.cp/overload.cc2
-rw-r--r--gdb/testsuite/gdb.cp/overload.exp3
5 files changed, 34 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cf66837..07cb80d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-15 Tom Tromey <tromey@redhat.com>
+
+ PR c++/15116:
+ * gdbtypes.c (types_equal): Handle TYPE_CODE_FUNC.
+
2013-03-14 Tom Tromey <tromey@redhat.com>
* gdb_bfd.c (struct gdb_bfd_data) <crc_computed, crc>:
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 12730d7..a1c4018 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2456,6 +2456,25 @@ types_equal (struct type *a, struct type *b)
if (a == b)
return 1;
+ /* Two function types are equal if their argument and return types
+ are equal. */
+ if (TYPE_CODE (a) == TYPE_CODE_FUNC)
+ {
+ int i;
+
+ if (TYPE_NFIELDS (a) != TYPE_NFIELDS (b))
+ return 0;
+
+ if (!types_equal (TYPE_TARGET_TYPE (a), TYPE_TARGET_TYPE (b)))
+ return 0;
+
+ for (i = 0; i < TYPE_NFIELDS (a); ++i)
+ if (!types_equal (TYPE_FIELD_TYPE (a, i), TYPE_FIELD_TYPE (b, i)))
+ return 0;
+
+ return 1;
+ }
+
return 0;
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2cf7345..9d0a7c4 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-15 Tom Tromey <tromey@redhat.com>
+
+ * gdb.cp/overload.cc (intintfunc): New.
+ * gdb.cp/overload.exp: Add regression test.
+
2013-03-15 Yao Qi <yao@codesourcery.com>
* gdb.threads/non-ldr-exc-1.exp (do_test): Fix the indent of
diff --git a/gdb/testsuite/gdb.cp/overload.cc b/gdb/testsuite/gdb.cp/overload.cc
index ba0678f..5c782a4 100644
--- a/gdb/testsuite/gdb.cp/overload.cc
+++ b/gdb/testsuite/gdb.cp/overload.cc
@@ -97,6 +97,8 @@ class D: C {};
int bar (A) { return 11; }
int bar (B) { return 22; }
+int intintfunc (int x) { return x; }
+
int main ()
{
char arg2 = 2;
diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp
index 3ebc642..9d49516 100644
--- a/gdb/testsuite/gdb.cp/overload.exp
+++ b/gdb/testsuite/gdb.cp/overload.exp
@@ -139,6 +139,9 @@ gdb_test "print foo_instance3" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\
gdb_test "print foo_instance1.overloadargs(1)" "\\$\[0-9\]+ = 1" \
"print call overloaded func 1 arg"
+# Regression test for overloading with function pointer type.
+gdb_test "print foo_instance1.overloadfnarg(23, intintfunc)" " = 23"
+
# If GDB fails to restore the selected frame properly after the
# inferior function call above (see GDB PR 1155 for an explanation of
# why this might happen), all the subsequent tests will fail. We