]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use attribute::unsigned_constant for DW_AT_data_member_location
authorTom Tromey <tromey@adacore.com>
Wed, 19 Mar 2025 20:02:12 +0000 (14:02 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 24 Apr 2025 19:25:08 +0000 (13:25 -0600)
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

gdb/dwarf2/read.c

index 4a142fe11bfb8a9315bdc6285a0114de9e755a00..aae74e91769fa5383824263f42e82b7cfaad285b 100644 (file)
@@ -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