From: Martin Galvan Date: Wed, 27 Apr 2016 15:01:14 +0000 (-0300) Subject: c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT X-Git-Tag: users/hjl/linux/release/2.26.51.0.2~1^2~54^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=476350ba4800f1144b125f6511a5e25b223cc90b;p=thirdparty%2Fbinutils-gdb.git c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT Currently c_value_print will turn struct reference values into pointers before doing a set of RTTI checks. This was introduced as a fix to PR c++/15401. If there's RTTI the pointer will be adjusted and converted back to a reference. However, if there's no RTTI the value will still be treated as a pointer during the remainder of the function. This patch moves the conversion down so that it's always performed when needed. Notice this currently has not user-visible effects, so can be seen as a small code cleanup. However, it'll be necessary for the bug-fix for handling synthetic C++ references. It causes no testsuite regressions. gdb/ChangeLog: 2016-04-26 Martin Galvan * c-valprint.c (c_value_print): Always convert val back to reference type if we converted it to a pointer type. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index df10de45abd..165c2a34f35 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-04-27 Martin Galvan + + * c-valprint.c (c_value_print): Always convert val back to reference + type if we converted it to a pointer type. + 2016-04-27 Andreas Arnez * configure.ac: Enhance configure check for babeltrace to reject diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 62552ec7fd9..e1da3d50e36 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -611,7 +611,7 @@ c_value_print (struct value *val, struct ui_file *stream, fprintf_filtered (stream, "("); if (value_entirely_available (val)) - { + { real_type = value_rtti_indirect_type (val, &full, &top, &using_enc); if (real_type) @@ -623,18 +623,19 @@ c_value_print (struct value *val, struct ui_file *stream, 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 attributes. */ } } - type_print (type, "", stream, -1); + + if (is_ref) + { + val = value_ref (value_ind (val)); + type = value_type (val); + } + + type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); val_type = type; }