aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ. Brobecker <brobecker@gnat.com>2004-01-09 14:08:21 +0000
committerJoel Brobecker <brobecke@gcc.gnu.org>2004-01-09 14:08:21 +0000
commitde99511b75b9c9a8c85b77f1019041a280da45bf (patch)
tree9cf823123dad10932c60b71b6f318d801966df66
parent41b19a2d9a81731ff3199c9a2318ee1ed7fecf9f (diff)
downloadgcc-de99511b75b9c9a8c85b77f1019041a280da45bf.zip
gcc-de99511b75b9c9a8c85b77f1019041a280da45bf.tar.gz
gcc-de99511b75b9c9a8c85b77f1019041a280da45bf.tar.bz2
dwarf2out.c (gen_enumeration_type_die): Return the DIE that we just created.
* dwarf2out.c (gen_enumeration_type_die): Return the DIE that we just created. (is_ada_subrange_type): DIEs for enumeration subtypes should be emitted as subrange types too. (subrange_type_die): Add handling of enumeration subtypes. From-SVN: r75582
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/dwarf2out.c41
2 files changed, 39 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 208ee94..ef58d8f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2004-01-09 J. Brobecker <brobecker@gnat.com>
+
+ * dwarf2out.c (gen_enumeration_type_die): Return the DIE that
+ we just created.
+ (is_ada_subrange_type): DIEs for enumeration subtypes should be
+ emitted as subrange types too.
+ (subrange_type_die): Add handling of enumeration subtypes.
+
2004-01-08 Richard Henderson <rth@redhat.com>
PR opt/12441
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 04ec675..ea68216 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3755,7 +3755,7 @@ static void gen_entry_point_die (tree, dw_die_ref);
static void gen_inlined_enumeration_type_die (tree, dw_die_ref);
static void gen_inlined_structure_type_die (tree, dw_die_ref);
static void gen_inlined_union_type_die (tree, dw_die_ref);
-static void gen_enumeration_type_die (tree, dw_die_ref);
+static dw_die_ref gen_enumeration_type_die (tree, dw_die_ref);
static dw_die_ref gen_formal_parameter_die (tree, dw_die_ref);
static void gen_unspecified_parameters_die (tree, dw_die_ref);
static void gen_formal_types_die (tree, dw_die_ref);
@@ -7807,12 +7807,28 @@ simple_type_size_in_bits (tree type)
static inline bool
is_ada_subrange_type (tree type)
{
- /* We do this for INTEGER_TYPEs that have names, parent types, and when
- we are compiling Ada code. */
- return (TREE_CODE (type) == INTEGER_TYPE
- && TYPE_NAME (type) != 0 && TREE_TYPE (type) != 0
- && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE
- && TREE_UNSIGNED (TREE_TYPE (type)) && is_ada ());
+ /* We should use a subrange type in the following situations:
+ - For Ada modular types: These types are stored as integer subtypes
+ of an unsigned integer type;
+ - For subtypes of an Ada enumeration type: These types are stored
+ as integer subtypes of enumeral types.
+
+ This subrange type is mostly for the benefit of debugger users.
+ A nameless type would therefore not be very useful, so no need
+ to generate a subrange type in these cases. */
+ tree subtype = TREE_TYPE (type);
+
+ if (is_ada ()
+ && TREE_CODE (type) == INTEGER_TYPE
+ && TYPE_NAME (type) != NULL_TREE
+ && subtype != NULL_TREE)
+ {
+ if (TREE_CODE (subtype) == INTEGER_TYPE && TREE_UNSIGNED (subtype))
+ return true;
+ if (TREE_CODE (subtype) == ENUMERAL_TYPE)
+ return true;
+ }
+ return false;
}
/* Given a pointer to a tree node for a subrange type, return a pointer
@@ -7828,7 +7844,10 @@ subrange_type_die (tree type, dw_die_ref context_die)
if (context_die == NULL)
context_die = comp_unit_die;
- subtype_die = base_type_die (TREE_TYPE (type));
+ if (TREE_CODE (TREE_TYPE (type)) == ENUMERAL_TYPE)
+ subtype_die = gen_enumeration_type_die (TREE_TYPE (type), context_die);
+ else
+ subtype_die = base_type_die (TREE_TYPE (type));
if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name);
@@ -10346,7 +10365,7 @@ gen_inlined_union_type_die (tree type, dw_die_ref context_die)
enumerated type name/value is listed as a child of the enumerated type
DIE. */
-static void
+static dw_die_ref
gen_enumeration_type_die (tree type, dw_die_ref context_die)
{
dw_die_ref type_die = lookup_type_die (type);
@@ -10359,7 +10378,7 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
add_name_attribute (type_die, type_tag (type));
}
else if (! TYPE_SIZE (type))
- return;
+ return type_die;
else
remove_AT (type_die, DW_AT_declaration);
@@ -10402,6 +10421,8 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
}
else
add_AT_flag (type_die, DW_AT_declaration, 1);
+
+ return type_die;
}
/* Generate a DIE to represent either a real live formal parameter decl or to