]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use attribute::signed_constant for fixed-point scale
authorTom Tromey <tromey@adacore.com>
Mon, 10 Mar 2025 16:03:17 +0000 (10:03 -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::signed_constant for
DW_AT_binary_scale and DW_AT_decimal_scale.  (FWIW these were the
attributes that first lead me to find this problem.)

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32680

gdb/dwarf2/read.c

index 8da0b38af824bdf34bb23585a336a453f3d6e9de..5751e762590469c867299eb99d4ad37e4cf144c9 100644 (file)
@@ -13398,14 +13398,14 @@ finish_fixed_point_type (struct type *type, const char *suffix,
     }
   else if (attr->name == DW_AT_binary_scale)
     {
-      LONGEST scale_exp = attr->constant_value (0);
+      LONGEST scale_exp = attr->signed_constant ().value_or (0);
       gdb_mpz &num_or_denom = scale_exp > 0 ? scale_num : scale_denom;
 
       num_or_denom <<= std::abs (scale_exp);
     }
   else if (attr->name == DW_AT_decimal_scale)
     {
-      LONGEST scale_exp = attr->constant_value (0);
+      LONGEST scale_exp = attr->signed_constant ().value_or (0);
       gdb_mpz &num_or_denom = scale_exp > 0 ? scale_num : scale_denom;
 
       num_or_denom = gdb_mpz::pow (10, std::abs (scale_exp));