OSDN Git Service

2003-11-17 Scott Snyder <snyder@fnal.gov>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Nov 2003 17:48:59 +0000 (17:48 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Nov 2003 17:48:59 +0000 (17:48 +0000)
PR debug/11325
* dwarf2out.c (struct die_struct): Add die_definition field.
(add_AT_specification): New.
(gen_subprogram_die, gen_variable_die,
gen_struct_or_union_type_die): Use it.
(prune_unused_types_mark): If we're marking a forward declaration,
also mark the full definition, if it exists.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73676 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/dwarf2out.c

index be235d9..8ab81d7 100644 (file)
@@ -1,3 +1,13 @@
+2003-11-17  Scott Snyder  <snyder@fnal.gov>
+
+       PR debug/11325
+       * dwarf2out.c (struct die_struct): Add die_definition field.
+       (add_AT_specification): New.
+       (gen_subprogram_die, gen_variable_die,
+       gen_struct_or_union_type_die): Use it.
+       (prune_unused_types_mark): If we're marking a forward declaration,
+       also mark the full definition, if it exists.
+
 2003-11-16  Nick Clifton  <nickc@redhat.com>
 
        * config/stormy16/stormy16.h (BUILD_VA_LIST_TYPE): Delete.
index 85e2d32..7db1621 100644 (file)
@@ -3332,6 +3332,7 @@ typedef struct die_struct GTY(())
   dw_die_ref die_parent;
   dw_die_ref die_child;
   dw_die_ref die_sib;
+  dw_die_ref die_definition; /* ref from a specification to its definition */
   dw_offset die_offset;
   unsigned long die_abbrev;
   int die_mark;
@@ -3599,6 +3600,7 @@ static void add_AT_string (dw_die_ref, enum dwarf_attribute, const char *);
 static inline const char *AT_string (dw_attr_ref);
 static int AT_string_form (dw_attr_ref);
 static void add_AT_die_ref (dw_die_ref, enum dwarf_attribute, dw_die_ref);
+static void add_AT_specification (dw_die_ref, dw_die_ref);
 static inline dw_die_ref AT_ref (dw_attr_ref);
 static inline int AT_ref_external (dw_attr_ref);
 static inline void set_AT_ref_external (dw_attr_ref, int);
@@ -4664,6 +4666,18 @@ add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_
   add_dwarf_attr (die, attr);
 }
 
+/* Add an AT_specification attribute to a DIE, and also make the back
+   pointer from the specification to the definition. */
+
+static inline void
+add_AT_specification (dw_die_ref die, dw_die_ref targ_die)
+{
+  add_AT_die_ref (die, DW_AT_specification, targ_die);
+  if (targ_die->die_definition)
+    abort ();
+  targ_die->die_definition = die;
+}
+
 static inline dw_die_ref
 AT_ref (dw_attr_ref a)
 {
@@ -10629,7 +10643,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
       else
        {
          subr_die = new_die (DW_TAG_subprogram, context_die, decl);
-         add_AT_die_ref (subr_die, DW_AT_specification, old_die);
+         add_AT_specification (subr_die, old_die);
          if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
            add_AT_unsigned (subr_die, DW_AT_decl_file, file_index);
          if (get_AT_unsigned (old_die, DW_AT_decl_line)
@@ -10849,7 +10863,7 @@ gen_variable_die (tree decl, dw_die_ref context_die)
           && get_AT_flag (old_die, DW_AT_declaration) == 1)
     {
       /* This is a definition of a C++ class level static.  */
-      add_AT_die_ref (var_die, DW_AT_specification, old_die);
+      add_AT_specification (var_die, old_die);
       if (DECL_NAME (decl))
        {
          unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
@@ -11295,7 +11309,7 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die)
                          scope_die, type);
       equate_type_number_to_die (type, type_die);
       if (old_die)
-       add_AT_die_ref (type_die, DW_AT_specification, old_die);
+       add_AT_specification (type_die, old_die);
       else
        add_name_attribute (type_die, type_tag (type));
     }
@@ -12504,6 +12518,11 @@ prune_unused_types_mark (dw_die_ref die, int dokids)
 
       /* Mark any referenced nodes.  */
       prune_unused_types_walk_attribs (die);
+
+      /* If this node is a specification,
+         also mark the definition, if it exists. */
+      if (get_AT_flag (die, DW_AT_declaration) && die->die_definition)
+        prune_unused_types_mark (die->die_definition, 1);
     }
 
   if (dokids && die->die_mark != 2)