This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] PATCH: fix bug w/ missing type attribute
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Mark Mitchell <mark at codesourcery dot com>, Kenneth Zadeck <zadeck at naturalbridge dot com>
- Date: Wed, 11 Oct 2006 12:44:00 -0400
- Subject: [lto] PATCH: fix bug w/ missing type attribute
Because DWARF doesn't have an explicit encoding of the void type, in some cases
a missing type attribute is used to represent void and needs to be checked for
explicitly. Last week I checked in a patch to fix the same problem in
lto_read_pointer_reference_type_DIE and lto_read_const_volatile_restrict_DIE,
and I just realized I missed the typedef case. This is already committed as
"obvious".
-Sandra
2006-10-11 Sandra Loosemore <sandra@codesourcery.com>
* gcc/lto/lto.c (lto_read_typedef_DIE): Treat missing type attribute
as void instead of error, for compatibility with dwarf2out.c behavior.
Index: gcc/lto/lto.c
===================================================================
*** gcc/lto/lto.c (revision 117637)
--- gcc/lto/lto.c (working copy)
*************** lto_read_typedef_DIE (lto_info_fd *fd,
*** 2434,2442 ****
}
LTO_END_READ_ATTRS ();
! /* The DW_AT_type and DW_AT_name attributes are required. */
! if (!base_type || !name)
lto_file_corrupt_error ((lto_fd *)fd);
/* Build the typedef. */
type = build_variant_type_copy (base_type);
decl = build_decl (TYPE_DECL, name, type);
--- 2434,2449 ----
}
LTO_END_READ_ATTRS ();
! /* The DW_AT_name attribute is required. */
! if (!name)
lto_file_corrupt_error ((lto_fd *)fd);
+ /* The DW_AT_type attribute is supposed to be required, but since DWARF
+ has no representation for the void type, dwarf2out.c omits the type
+ attribute in that case. So, in order to allow GCC's output to be
+ read in again, we have to interpret a missing base type attribute as
+ the void type, too. */
+ if (!base_type)
+ base_type = void_type_node;
/* Build the typedef. */
type = build_variant_type_copy (base_type);
decl = build_decl (TYPE_DECL, name, type);