+2013-05-22 Tom Tromey <tromey@redhat.com>
+
+ PR c++/15401:
+ * c-valprint.c (c_value_print): Use value_addr for
+ references. Convert back to reference type with value_ref.
+
2013-05-22 Eli Zaretskii <eliz@gnu.org>
* windows-nat.c (handle_unload_dll): Don't call solib_add for the
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, "(");
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
+2013-05-22 Tom Tromey <tromey@redhat.com>
+
+ * gdb.cp/class2.cc (main): New local 'aref'.
+ * gdb.cp/class2.exp: Check printing of 'aref'.
+
2013-05-22 Doug Evans <dje@google.com>
* gdb.threads/wp-replication.c (main): Insert some code at the start
gdb_test "p acp" "= \\(C \\*\\) ${hex}"
gdb_test "p acp->c1" "\\(A \\*\\) 0x0"
gdb_test "p acp->c2" "\\(A \\*\\) ${hex}f"
+
+# Regression test for PR c++/15401.
+# Check that the type printed is a reference.
+gdb_test "p aref" " = \\(A \\&\\) .*"