aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-03-09 07:36:26 -0700
committerTom Tromey <tromey@adacore.com>2021-03-09 07:36:26 -0700
commitccdc02ed07bbed9468c275a943fc5a970e949e99 (patch)
treeda564e8abf704100761bc9f9bb28145dd51df327 /gdb/eval.c
parent5dc75cf3254c1b3c5b62125f47b543407836a4b6 (diff)
downloadgdb-ccdc02ed07bbed9468c275a943fc5a970e949e99.zip
gdb-ccdc02ed07bbed9468c275a943fc5a970e949e99.tar.gz
gdb-ccdc02ed07bbed9468c275a943fc5a970e949e99.tar.bz2
Fix function call regression in new evaluator
The internal AdaCore test suite revealed a bug in the new evaluator. A hunk of evaluate_funcall was not correctly transcribed. This was not caught in my original testing because the feature in question was apparently not tested in gdb. This patch fixes the oversight. The idea here is that ordinary function calls should use the function's formal parameter types as the expected types of subexpressions. Regression tested on x86-64 Fedora 32. gdb/ChangeLog 2021-03-09 Tom Tromey <tromey@adacore.com> * eval.c (operation::evaluate_funcall): Use function formal parameter types when evaluating. gdb/testsuite/ChangeLog 2021-03-09 Tom Tromey <tromey@adacore.com> * gdb.base/cast-call.exp: New file. * gdb.base/cast-call.c: New file.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 5af728a..530ff15 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -687,8 +687,16 @@ operation::evaluate_funcall (struct type *expect_type,
std::vector<value *> vals (args.size ());
value *callee = evaluate_with_coercion (exp, noside);
+ struct type *type = value_type (callee);
+ if (type->code () == TYPE_CODE_PTR)
+ type = TYPE_TARGET_TYPE (type);
for (int i = 0; i < args.size (); ++i)
- vals[i] = args[i]->evaluate_with_coercion (exp, noside);
+ {
+ if (i < type->num_fields ())
+ vals[i] = args[i]->evaluate (type->field (i).type (), exp, noside);
+ else
+ vals[i] = args[i]->evaluate_with_coercion (exp, noside);
+ }
return evaluate_subexp_do_call (exp, noside, callee, vals,
function_name, expect_type);