diff options
author | Pierre-Marie de Rodat <derodat@adacore.com> | 2017-01-03 08:54:57 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2017-01-03 08:54:57 +0000 |
commit | f76f096ec710986d1153d7f3179352d0a614a7d2 (patch) | |
tree | 2edda5bc25f4d7c3051a2d55a4bc670f4457686b /gcc | |
parent | 51ad5d5ba376c1eaf76fee8e2457b8bfb9b000c1 (diff) | |
download | gcc-f76f096ec710986d1153d7f3179352d0a614a7d2.zip gcc-f76f096ec710986d1153d7f3179352d0a614a7d2.tar.gz gcc-f76f096ec710986d1153d7f3179352d0a614a7d2.tar.bz2 |
DWARF: add DW_AT_encoding attributes for DW_TAG_enumeration_type DIEs
Currently, the DWARF description does not specify the signedness of the
representation of enumeration types. This is a problem in some
contexts where DWARF consumers need to determine if value X is greater
than value Y.
For instance in Ada:
type Enum_Type is ( A, B, C, D);
for Enum_Type use (-1, 0, 1, 2);
type Rec_Type (E : Enum_Type) is record
when A .. B => null;
when others => B : Booleann;
end record;
The above can be described in DWARF the following way:
DW_TAG_enumeration_type(Enum_Type)
| DW_AT_byte_size: 1
DW_TAG_enumerator(A)
| DW_AT_const_value: -1
DW_TAG_enumerator(B)
| DW_AT_const_value: 0
DW_TAG_enumerator(C)
| DW_AT_const_value: 1
DW_TAG_enumerator(D)
| DW_AT_const_value: 2
DW_TAG_structure_type(Rec_Type)
DW_TAG_member(E)
| DW_AT_type: <Enum_Type>
DW_TAG_variant_part
| DW_AT_discr: <E>
DW_TAG_variant
| DW_AT_discr_list: DW_DSC_range 0x7f 0
DW_TAG_variant
| DW_TAG_member(b)
DWARF consumers need to know that enumerators (A, B, C and D) are signed
in order to determine the set of E values for which Rec_Type has a B
field. In practice, they need to know how to interpret the 0x7f LEB128
number above (-1, not 127).
When in non-strict DWARF mode, this patch adds a DW_AT_encoding
attribute to generated DW_TAG_enumeration_type DIEs to make this
signedness explicit.
gcc/
* dwarf2out.c (gen_enumeration_type_die): When
-gno-strict-dwarf, add a DW_AT_encoding attribute.
From-SVN: r244015
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index af5185a..2182cff 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-01-03 Pierre-Marie de Rodat <derodat@adacore.com> + + * dwarf2out.c (gen_enumeration_type_die): When + -gno-strict-dwarf, add a DW_AT_encoding attribute. + 2017-01-03 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/78965 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index edb7169..15b9a30 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -20930,6 +20930,11 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die) if (ENUM_IS_OPAQUE (type)) add_AT_flag (type_die, DW_AT_declaration, 1); } + if (!dwarf_strict) + add_AT_unsigned (type_die, DW_AT_encoding, + TYPE_UNSIGNED (type) + ? DW_ATE_unsigned + : DW_ATE_signed); } else if (! TYPE_SIZE (type)) return type_die; |