aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcall.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-07-13 04:31:42 +0000
committerDaniel Jacobowitz <drow@false.org>2006-07-13 04:31:42 +0000
commitfb933624929d0716f25db8d1096557e7f5e72440 (patch)
treee216dad7d0d61e68304e7ab329fe58c5c850799b /gdb/infcall.c
parentd49c44d5f19771810279034d93060d13c13f0937 (diff)
downloadgdb-fb933624929d0716f25db8d1096557e7f5e72440.zip
gdb-fb933624929d0716f25db8d1096557e7f5e72440.tar.gz
gdb-fb933624929d0716f25db8d1096557e7f5e72440.tar.bz2
gdb/
* infcall.c (value_arg_coerce): Use value_cast_pointers for references. Avoid value_cast to a reference type. Don't silently convert pointers to references. * valops.c (value_cast_pointers): New, based on value_cast. (value_cast): Use it. Reject reference types. (value_ref): New. (typecmp): Use it. * value.h (value_cast_pointers, value_ref): New prototypes. gdb/testsuite/ * gdb.cp/ref-params.exp: New test. * gdb.cp/ref-params.cc: New source file. * gdb.cp/Makefile.in (EXECUTABLES): Add ref-params.
Diffstat (limited to 'gdb/infcall.c')
-rw-r--r--gdb/infcall.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gdb/infcall.c b/gdb/infcall.c
index c8a6334..3a1ad6a 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -109,14 +109,20 @@ value_arg_coerce (struct value *arg, struct type *param_type,
switch (TYPE_CODE (type))
{
case TYPE_CODE_REF:
- if (TYPE_CODE (arg_type) != TYPE_CODE_REF
- && TYPE_CODE (arg_type) != TYPE_CODE_PTR)
- {
- arg = value_addr (arg);
- deprecated_set_value_type (arg, param_type);
- return arg;
- }
- break;
+ {
+ struct value *new_value;
+
+ if (TYPE_CODE (arg_type) == TYPE_CODE_REF)
+ return value_cast_pointers (type, arg);
+
+ /* Cast the value to the reference's target type, and then
+ convert it back to a reference. This will issue an error
+ if the value was not previously in memory - in some cases
+ we should clearly be allowing this, but how? */
+ new_value = value_cast (TYPE_TARGET_TYPE (type), arg);
+ new_value = value_ref (new_value);
+ return new_value;
+ }
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
case TYPE_CODE_BOOL: