From b7b4a8ebb6c36f9aedea200095c850c3347eb42b Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 10 Mar 2025 10:03:17 -0600 Subject: [PATCH] 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 --- gdb/dwarf2/read.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)); -- 2.39.5