From: Tom Tromey Date: Wed, 19 Mar 2025 20:02:12 +0000 (-0600) Subject: Use attribute::unsigned_constant for DW_AT_data_member_location X-Git-Tag: binutils-2_45~791 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6967933c5acf85a6c8d7322b1aff529ce86507e4;p=thirdparty%2Fbinutils-gdb.git Use attribute::unsigned_constant for DW_AT_data_member_location This changes the DWARF reader to use attribute::unsigned_constant for DW_AT_data_member_location. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32680 --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4a142fe11bf..aae74e91769 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9923,7 +9923,7 @@ handle_member_location (struct die_info *die, struct dwarf2_cu *cu, so if we see it, we can assume that a constant form is really a constant and not a section offset. */ if (attr->form_is_constant ()) - *offset = attr->constant_value (0); + *offset = attr->unsigned_constant ().value_or (0); else if (attr->form_is_section_offset ()) dwarf2_complex_location_expr_complaint (); else if (attr->form_is_block () @@ -9963,7 +9963,7 @@ handle_member_location (struct die_info *die, struct dwarf2_cu *cu, { if (attr->form_is_constant ()) { - LONGEST offset = attr->constant_value (0); + LONGEST offset = attr->unsigned_constant ().value_or (0); /* Work around this GCC 11 bug, where it would erroneously use -1 data member locations, instead of 0: @@ -12288,7 +12288,7 @@ mark_common_block_symbol_computed (struct symbol *sym, if (member_loc->form_is_constant ()) { - offset = member_loc->constant_value (0); + offset = member_loc->unsigned_constant ().value_or (0); baton->size += 1 /* DW_OP_addr */ + cu->header.addr_size; } else