This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't add DW_AT_name to DW_TAG_{const,volatile}_type


Hi!

As reported in http://bugzilla.redhat.com/526970 for C GCC emits
struct A { int i; };
const char *p;
        .uleb128 0x2    # (DIE (0x2d) DW_TAG_structure_type)
        .ascii "A\0"    # DW_AT_name
        .byte   0x4     # DW_AT_byte_size
        .byte   0x1     # DW_AT_decl_file (rh526970.c)
        .byte   0x1     # DW_AT_decl_line
        .long   0x44    # DW_AT_sibling
...
        .uleb128 0x6    # (DIE (0x5f) DW_TAG_pointer_type)
        .byte   0x8     # DW_AT_byte_size
        .long   0x65    # DW_AT_type
        .uleb128 0x7    # (DIE (0x65) DW_TAG_const_type)
        .ascii "A\0"    # DW_AT_name
        .long   0x2d    # DW_AT_type
        .byte   0x0     # end of children of DIE 0xb
...
Note that both the DW_TAG_const_type and DW_TAG_structure_type it refers to
have DW_AT_name, while in C only DW_TAG_structure_type should have a name.
In C++ TYPE_NAME is TYPE_DECL, so this bug doesn't exist.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for
trunk?

2009-10-05  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2out.c (modified_type_die): Don't add DW_AT_name to
	DW_TAG_{const,volatile}_type if its DW_AT_type already has the
	same name and isn't the main variant.

--- gcc/dwarf2out.c.jj	2009-10-05 10:07:22.000000000 +0200
+++ gcc/dwarf2out.c	2009-10-05 13:41:27.000000000 +0200
@@ -11971,10 +11971,16 @@ modified_type_die (tree type, int is_con
 
   /* Builtin types don't have a DECL_ORIGINAL_TYPE.  For those,
      don't output a DW_TAG_typedef, since there isn't one in the
-     user's program; just attach a DW_AT_name to the type.  */
+     user's program; just attach a DW_AT_name to the type.
+     Don't attach a DW_AT_name to DW_TAG_const_type or DW_TAG_volatile_type
+     if the base type already has the same name.  */
   if (name
-      && (TREE_CODE (name) != TYPE_DECL
-	  || (TREE_TYPE (name) == qualified_type && DECL_NAME (name))))
+      && ((TREE_CODE (name) != TYPE_DECL
+	   && (qualified_type == TYPE_MAIN_VARIANT (type)
+	       || (!is_const_type && !is_volatile_type)))
+	  || (TREE_CODE (name) == TYPE_DECL
+	      && TREE_TYPE (name) == qualified_type
+	      && DECL_NAME (name))))
     {
       if (TREE_CODE (name) == TYPE_DECL)
 	/* Could just call add_name_and_src_coords_attributes here,

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]