From: Tom Tromey Date: Mon, 10 Mar 2025 16:03:17 +0000 (-0600) Subject: Use attribute::signed_constant for fixed-point scale X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b7b4a8ebb6c36f9aedea200095c850c3347eb42b;p=thirdparty%2Fbinutils-gdb.git Use attribute::signed_constant for fixed-point scale 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 --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8da0b38af82..5751e762590 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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));