This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lto] fix error in dwarf2out_finish
- From: "Daniel Berlin" <dberlin at dberlin dot org>
- To: gcc-patches at gcc dot gnu dot org, zadeck at naturalbridge dot com
- Date: Fri, 7 Dec 2007 20:09:19 -0500
- Subject: Re: [lto] fix error in dwarf2out_finish
- References: <20071207231104.GB11065@codesourcery.com>
On 12/7/07, Nathan Froyd <froydnj@codesourcery.com> wrote:
> We were asserting because things didn't expect to see BLOCKs as the
> context of something. Fixed thusly.
>
Blocks are a valid context of something.
That's why we have gen_block_die, and gen_lexical_block_die.
Flat out ignoring them is the wrong thing to do.
> Committed to the LTO branch.
>
> -Nathan
>
> 2007-12-07 Nathan Froyd <froydnj@codesourcery.com>
>
> * dwarf2out.c (containing_decl_for_block): New function.
> (force_block_die): Call it.
> (dwarf2out_finish): Call it if we have a BLOCK for our context.
>
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c (revision 130658)
> +++ gcc/dwarf2out.c (working copy)
> @@ -13498,10 +13498,10 @@ force_die_for_context (tree context)
> gcc_unreachable ();
> }
>
> -/* Returns the DIE for block. A DIE will always be returned. */
> +/* Returns the containing DECL for block. A DECL will always be returned. */
>
> -static dw_die_ref
> -force_block_die (tree block)
> +static tree
> +containing_decl_for_block (tree block)
> {
> tree context = block;
>
> @@ -13518,7 +13518,15 @@ force_block_die (tree block)
>
> gcc_assert (context);
>
> - return force_decl_die (context);
> + return context;
> +}
> +
> +/* Returns the DIE for block. A DIE will always be returned. */
> +
> +static dw_die_ref
> +force_block_die (tree block)
> +{
> + return force_decl_die (containing_decl_for_block (block));
> }
>
> /* Returns the DIE for decl. A DIE will always be returned. */
> @@ -14929,6 +14937,9 @@ dwarf2out_finish (const char *filename)
> else if (TYPE_P (node->created_for))
> context = TYPE_CONTEXT (node->created_for);
>
> + if (TREE_CODE (context) == BLOCK)
> + context = containing_decl_for_block (context);
> +
> gcc_assert (context
> && (TREE_CODE (context) == FUNCTION_DECL
> || TREE_CODE (context) == NAMESPACE_DECL));
>