From: Doug Evans Date: Thu, 25 Nov 2010 19:42:31 +0000 (+0000) Subject: * dwarf2read.c (dwarf2_const_value_data): Never sign extend. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9e7c18860a34cb99f116a0d702009470e63bc33;p=thirdparty%2Fbinutils-gdb.git * dwarf2read.c (dwarf2_const_value_data): Never sign extend. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 93a1853f735..05a4fca83be 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2010-11-25 Tom Tromey + + * dwarf2read.c (dwarf2_const_value_data): Never sign extend. + 2010-11-18 Phil Muldoon PR mi/11407 diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1e752357e00..55b3f082877 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9165,8 +9165,13 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym, } -/* Given an attr with a DW_FORM_dataN value in host byte order, sign- - or zero-extend it as appropriate for the symbol's type. */ +/* Given an attr with a DW_FORM_dataN value in host byte order, + zero-extend it as appropriate for the symbol's type. The DWARF + standard (v4) is not entirely clear about the meaning of using + DW_FORM_dataN for a constant with a signed type, where the type is + wider than the data. The conclusion of a discussion on the DWARF + list was that this is unspecified. We choose to always zero-extend + because that is the interpretation long in use by GCC. */ static void dwarf2_const_value_data (struct attribute *attr, struct symbol *sym, @@ -9175,12 +9180,7 @@ dwarf2_const_value_data (struct attribute *attr, LONGEST l = DW_UNSND (attr); if (bits < sizeof (l) * 8) - { - if (TYPE_UNSIGNED (SYMBOL_TYPE (sym))) - l &= ((LONGEST) 1 << bits) - 1; - else - l = (l << (sizeof (l) * 8 - bits)) >> (sizeof (l) * 8 - bits); - } + l &= ((LONGEST) 1 << bits) - 1; SYMBOL_VALUE (sym) = l; SYMBOL_CLASS (sym) = LOC_CONST;