dwarf2out.c (gen_enumeration_type_die): Fix HOST_BITS_PER_WIDE_INT dependency behavio...
authorJulian Brown <julian@codesourcery.com>
Wed, 24 Apr 2013 10:07:24 +0000 (10:07 +0000)
committerChung-Lin Tang <cltang@gcc.gnu.org>
Wed, 24 Apr 2013 10:07:24 +0000 (10:07 +0000)
2013-04-24  Julian Brown  <julian@codesourcery.com>
    Chung-Lin Tang  <cltang@codesourcery.com>

* dwarf2out.c (gen_enumeration_type_die): Fix HOST_BITS_PER_WIDE_INT
dependency behavior in enumeration type DIE generation. Add TODO
note to comments about future DW_FORM_sdata/udata re-work of related
code.

Co-Authored-By: Chung-Lin Tang <cltang@codesourcery.com>
From-SVN: r198219

gcc/ChangeLog
gcc/dwarf2out.c

index f280abea5d4d37a55247268807b79504a410427e..2adf8a73a7a141fcdcdda6f03970dfb56b6a0ac6 100644 (file)
@@ -1,3 +1,11 @@
+2013-04-24  Julian Brown  <julian@codesourcery.com>
+           Chung-Lin Tang  <cltang@codesourcery.com>
+
+       * dwarf2out.c (gen_enumeration_type_die): Fix HOST_BITS_PER_WIDE_INT
+       dependency behavior in enumeration type DIE generation. Add TODO
+       note to comments about future DW_FORM_sdata/udata re-work of related
+       code.
+
 2013-04-23  Lawrence Crowl  <crowl@google.com>
 
        * Makefile.in: Update as needed below.
index b067b861083aa7b5a40c0682d069c9f3a96d85e1..6fe1e6916af5d386548869e92e00575dc1d173b9 100644 (file)
@@ -17027,15 +17027,27 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
          if (TREE_CODE (value) == CONST_DECL)
            value = DECL_INITIAL (value);
 
-         if (host_integerp (value, TYPE_UNSIGNED (TREE_TYPE (value))))
+         if (host_integerp (value, TYPE_UNSIGNED (TREE_TYPE (value)))
+             && (simple_type_size_in_bits (TREE_TYPE (value))
+                 <= HOST_BITS_PER_WIDE_INT || host_integerp (value, 0)))
            /* 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));
+              will appear to have negative values in the debugger.
+
+              TODO: the above comment is wrong, DWARF2 does provide
+              DW_FORM_sdata/DW_FORM_udata to represent signed/unsigned data.
+              This should be re-worked to use correct signed/unsigned
+              int/double tags for all cases, instead of always treating as
+              signed.  */
+           add_AT_int (enum_die, DW_AT_const_value, TREE_INT_CST_LOW (value));
+         else
+           /* Enumeration constants may be wider than HOST_WIDE_INT.  Handle
+              that here.  */
+           add_AT_double (enum_die, DW_AT_const_value,
+                          TREE_INT_CST_HIGH (value), TREE_INT_CST_LOW (value));
        }
 
       add_gnat_descriptive_type_attribute (type_die, type, context_die);