From 5bb2ed2c242927e707409f2122e843a440377458 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 1 Mar 2004 04:07:36 +0000 Subject: [PATCH] re PR debug/14328 (gcc3.2.2 generates incorrect debugging enum values) PR debug/14328 * dwarf2out.c (gen_enumeration_type_die): Output all enumeration constants as signed values. From-SVN: r78690 --- gcc/ChangeLog | 4 ++++ gcc/dwarf2out.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6d0f8ce21a9..a13eb92103b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2004-02-29 Mark Mitchell + PR debug/14328 + * dwarf2out.c (gen_enumeration_type_die): Output all enumeration + constants as signed values. + PR middle-end/13448 * c-tree.h (readonly_warning): Rename to ... (readonly_error): ... this. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 841827ba597..599b6c9c643 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -10691,20 +10691,20 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die) link != NULL; link = TREE_CHAIN (link)) { dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die, link); + tree value = TREE_VALUE (link); add_name_attribute (enum_die, IDENTIFIER_POINTER (TREE_PURPOSE (link))); - if (host_integerp (TREE_VALUE (link), - TREE_UNSIGNED (TREE_TYPE (TREE_VALUE (link))))) - { - if (tree_int_cst_sgn (TREE_VALUE (link)) < 0) - add_AT_int (enum_die, DW_AT_const_value, - tree_low_cst (TREE_VALUE (link), 0)); - else - add_AT_unsigned (enum_die, DW_AT_const_value, - tree_low_cst (TREE_VALUE (link), 1)); - } + if (host_integerp (value, TREE_UNSIGNED (TREE_TYPE (value)))) + /* DWARF2 does not provide a way of indicating whether or + not enumeration constants are signed or unsigned. GDB + always assumes the values are signed, so we output all + values as if they were signed. That means that + enumeration constants with very large unsigned values + will appear to have negative values in the debugger. */ + add_AT_int (enum_die, DW_AT_const_value, + tree_low_cst (value, tree_int_cst_sgn (value) > 0)); } } else -- 2.30.2