From: brobecke Date: Fri, 9 Jan 2004 14:08:21 +0000 (+0000) Subject: * dwarf2out.c (gen_enumeration_type_die): Return the DIE that X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=93c7db8290d872a8befabc751b2983212cfac418 * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75582 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 208ee947d7c..ef58d8fe35a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-01-09 J. Brobecker + + * 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 PR opt/12441 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 04ec675d26f..ea68216c3a8 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