Allow calling of variadic C++ functions

Currently, it's not possible to call a variadic C++ function:
```
(gdb) print sum_vararg_int(1, 10)
Cannot resolve function sum_vararg_int to any overloaded instance
(gdb) print sum_vararg_int(2, 20, 30)
Cannot resolve function sum_vararg_int to any overloaded instance
```

It's because all additional arguments get the TOO_FEW_PARAMS_BADNESS
rank by rank_function, which disqualifies the function.

To fix this, I've created the new VARARG_BADNESS rank, which is
used only for additional arguments of variadic functions, allowing
them to be called:
```
(gdb) print sum_vararg_int(1, 10)
$1 = 10
(gdb) print sum_vararg_int(2, 20, 30)
$2 = 50
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28589
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Hannes Domani
2021-11-14 16:19:31 +01:00
parent 8cb16b6858
commit 1d2f86b6b7
5 changed files with 55 additions and 6 deletions

View File

@@ -2735,7 +2735,8 @@ extern int compare_badness (const badness_vector &,
const badness_vector &);
extern badness_vector rank_function (gdb::array_view<type *> parms,
gdb::array_view<value *> args);
gdb::array_view<value *> args,
bool varargs = false);
extern struct rank rank_one_type (struct type *, struct type *,
struct value *);