Fix calling prototyped functions via function pointers
authorPedro Alves <palves@redhat.com>
Mon, 4 Sep 2017 19:21:13 +0000 (20:21 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 4 Sep 2017 19:21:13 +0000 (20:21 +0100)
commit54990598c4c74b6af113baf801064d3b1837973f
treeae03eeeaca8298edb3fc821edcc4841afbce58df
parent34d16ea2a144cdac8a89050d9aab723fb675cb45
Fix calling prototyped functions via function pointers

Calling a prototyped function via a function pointer with the right
prototype doesn't work correctly, if the called function requires
argument coercion...  Like, e.g., with:

  float mult (float f1, float f2) { return f1 * f2; }

  (gdb) p mult (2, 3.5)
  $1 = 7
  (gdb) p ((float (*) (float, float)) mult) (2, 3.5)
  $2 = 0

both calls should have returned the same, of course.  The problem is
that GDB misses marking the type of the function pointer target as
prototyped...

Without the fix, the new test fails like this:

 (gdb) p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)
 $30 = 0
 (gdb) FAIL: gdb.base/callfuncs.exp: p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

* gdbtypes.c (lookup_function_type_with_arguments): Mark function
types with more than one parameter as prototyped.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

* gdb.base/callfuncs.exp (do_function_calls): New parameter
"prototypes".  Test calling float functions via prototyped and
unprototyped function pointers.
(perform_all_tests): New parameter "prototypes".  Pass it down.
(top level): Pass down "prototypes" parameter to
perform_all_tests.
gdb/ChangeLog
gdb/gdbtypes.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/callfuncs.exp
This page took 0.032282 seconds and 4 git commands to generate.