diff options
author | Tom Tromey <tromey@adacore.com> | 2025-03-20 07:52:24 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-04-24 13:25:08 -0600 |
commit | cdcd13791f7de81f80ab12f5426fe002430f38b6 (patch) | |
tree | ff06fb0f6b21f532cf217b233981b222283c7938 | |
parent | 6ad5f5b6c08ea6b9733d64f77ab710d0b30dde09 (diff) | |
download | binutils-cdcd13791f7de81f80ab12f5426fe002430f38b6.zip binutils-cdcd13791f7de81f80ab12f5426fe002430f38b6.tar.gz binutils-cdcd13791f7de81f80ab12f5426fe002430f38b6.tar.bz2 |
Use attribute::signed_constant in attribute::as_boolean
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
-rw-r--r-- | gdb/dwarf2/attribute.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 7d6372d..8ff0353 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -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; } |