]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use attribute::signed_constant in attribute::as_boolean
authorTom Tromey <tromey@adacore.com>
Thu, 20 Mar 2025 13:52:24 +0000 (07:52 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 24 Apr 2025 19:25:08 +0000 (13:25 -0600)
This changes attribute::as_boolean to use attribute::signed_constant.
This is maybe overkill but lets any reasonable constant form through.

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

gdb/dwarf2/attribute.c

index 7d6372d15745d87b0b6fc354b9c231f2337872d9..8ff03531613898e02d375e87c252a5982d79a02a 100644 (file)
@@ -326,5 +326,8 @@ attribute::as_boolean () const
     return true;
   else if (form == DW_FORM_flag)
     return u.unsnd != 0;
-  return constant_value (0) != 0;
+  /* Using signed_constant here will work even for the weird case
+     where a negative value is provided.  Probably doesn't matter but
+     also seems harmless.  */
+  return signed_constant ().value_or (0) != 0;
 }