PR c++/15116:
authorTom Tromey <tromey@redhat.com>
Fri, 15 Mar 2013 17:10:45 +0000 (17:10 +0000)
committerTom Tromey <tromey@redhat.com>
Fri, 15 Mar 2013 17:10:45 +0000 (17:10 +0000)
     * gdbtypes.c (types_equal): Handle TYPE_CODE_FUNC.
gdb/testsuite
     * gdb.cp/overload.cc (intintfunc): New.
     * gdb.cp/overload.exp: Add regression test.

gdb/ChangeLog
gdb/gdbtypes.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/overload.cc
gdb/testsuite/gdb.cp/overload.exp

index cf668375e2f04faeb1c891c3a342adb3f1512a06..07cb80d4d343e584a6145de7b86468697d1afe40 100644 (file)
@@ -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>:
index 12730d7b12bad3aff0b13e1921a87743513e0cb2..a1c4018e69ddf09d52ad0bd68c2365f3b56ab40b 100644 (file)
@@ -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;
 }
 
index 2cf73451e8a48d0a913c63b9f055f9d129841e66..9d0a7c473c3a7427fceaa0b4882e1bb188a869f6 100644 (file)
@@ -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
index ba0678f496787b4d2de504d854aad4fda9796f97..5c782a461048580ebe7dd03f749d1c14e5194089 100644 (file)
@@ -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;
index 3ebc6423e0529cec6e4e731815fdbde1c6c43b20..9d495167cd0bba4321836bb76060e79d8acebec2 100644 (file)
@@ -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
This page took 0.044782 seconds and 4 git commands to generate.