diff options
author | Tom Tromey <tromey@redhat.com> | 2013-05-22 20:51:49 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2013-05-22 20:51:49 +0000 |
commit | 5f2e6b00f863fc8f334d2506b96b055ef70394ed (patch) | |
tree | de025e8ae9b9dc5499d9c750267e9609d6ab2d43 /gdb/c-valprint.c | |
parent | c77c0862b26d536f91187c34c510cee96bef1f7a (diff) | |
download | gdb-5f2e6b00f863fc8f334d2506b96b055ef70394ed.zip gdb-5f2e6b00f863fc8f334d2506b96b055ef70394ed.tar.gz gdb-5f2e6b00f863fc8f334d2506b96b055ef70394ed.tar.bz2 |
PR c++/15401:
* c-valprint.c (c_value_print): Use value_addr for
references. Convert back to reference type with value_ref.
gdb/testsuite
* gdb.cp/class2.cc (main): New local 'aref'.
* gdb.cp/class2.exp: Check printing of 'aref'.
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r-- | gdb/c-valprint.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 646aed7..ce2c29d 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -497,18 +497,11 @@ c_value_print (struct value *val, struct ui_file *stream, else if (options->objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS)) { + int is_ref = TYPE_CODE (type) == TYPE_CODE_REF; + + if (is_ref) + val = value_addr (val); - if (TYPE_CODE(type) == TYPE_CODE_REF) - { - /* Copy value, change to pointer, so we don't get an - error about a non-pointer type in - value_rtti_target_type. */ - struct value *temparg; - temparg=value_copy(val); - deprecated_set_value_type - (temparg, lookup_pointer_type (TYPE_TARGET_TYPE (type))); - val = temparg; - } /* Pointer to class, check real type of object. */ fprintf_filtered (stream, "("); @@ -522,7 +515,14 @@ c_value_print (struct value *val, struct ui_file *stream, type = real_type; /* Need to adjust pointer value. */ - val = value_from_pointer (type, value_as_address (val) - top); + val = value_from_pointer (real_type, + value_as_address (val) - top); + + if (is_ref) + { + val = value_ref (value_ind (val)); + type = value_type (val); + } /* Note: When we look up RTTI entries, we don't get any information on const or volatile |