diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 6ea7324..32fab58 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -12569,7 +12569,7 @@ add_pure_or_virtual_attribute (dw_die_ref die, tree func_decl) 0)); /* GNU extension: Record what type this method came from originally. */ - if (debug_info_level > DINFO_LEVEL_TERSE) + if (debug_info_level > DINFO_LEVEL_TERSE && DECL_CONTEXT (func_decl)) add_AT_die_ref (die, DW_AT_containing_type, lookup_type_die (DECL_CONTEXT (func_decl))); } diff --git a/gcc/tree.c b/gcc/tree.c index 0454953..1e46f24 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -4069,6 +4069,11 @@ reset_decl_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED) TREE_LANG_FLAG_5 (decl) = 0; TREE_LANG_FLAG_6 (decl) = 0; + if (TREE_CODE (decl) != FIELD_DECL) + /* Ignore any intervening types, because we + are going to clear their TYPE_CONTEXT fields. */ + DECL_CONTEXT (decl) = decl_function_context (decl); + if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL) DECL_CONTEXT (decl) = NULL_TREE; @@ -4131,15 +4136,6 @@ reset_decl_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED) in cgraph_node. */ DECL_CONTEXT (decl) = NULL_TREE; } - /* FIXME lto: Ideally, we would like to flatten out the nesting - of other non-field declarations within types, however this does - not work. This should be investigated further. */ -#if 0 - else if (TREE_CODE (decl) != FIELD_DECL) - /* Ignore any intervening types, because we - are going to clear their TYPE_CONTEXT fields. */ - DECL_CONTEXT (decl) = decl_function_context (decl); -#endif return 1; }