diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e589d2ac3c..9490dd36ebe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-11-18 Richard Guenther + + PR lto/45089 + * dwarf2out.c (add_AT_die_ref): Work around LTO losing types + when checking is not enabled. + 2010-11-18 Richard Guenther PR lto/46525 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 4eade28815a..ea3852e172f 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -7362,6 +7362,15 @@ add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_ { dw_attr_node attr; +#ifdef ENABLE_CHECKING + gcc_assert (targ_die != NULL); +#else + /* With LTO we can end up trying to reference something we didn't create + a DIE for. Avoid crashing later on a NULL referenced DIE. */ + if (targ_die == NULL) + return; +#endif + attr.dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_die_ref; attr.dw_attr_val.v.val_die_ref.die = targ_die;