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 to dwarf2out.c for c++/22489


Mark's change to lazily declare synthesized methods broke dwarf2 output because we expect the declaration DIE to be generated when we generate the DIE for the class, but if we don't create the decl until later that doesn't happen. This patch fixes that by adding the declaration die to the class when we want to point to it.

I also fixed a bug in force_type/decl_die that caused us to generate duplicate DIEs.

Tested x86_64-pc-linux-gnu, applied to trunk and 4.0 branch.
2005-11-12  Jason Merrill  <jason@redhat.com>

	PR c++/22489
	* dwarf2out.c (gen_subprogram_die): Force a declaration die for
	lazily declared methods.
	(force_decl_die): Stop if forcing out the context already make a
	DIE for the decl.
	(force_type_die): Likewise.

Index: dwarf2out.c
===================================================================
*** dwarf2out.c	(revision 106738)
--- dwarf2out.c	(working copy)
*************** gen_subprogram_die (tree decl, dw_die_re
*** 11478,11483 ****
--- 11478,11490 ----
        gcc_assert (!old_die);
      }
  
+   /* Now that the C++ front end lazily declares artificial member fns, we
+      might need to retrofit the declaration into its class.  */
+   if (!declaration && !origin && !old_die
+       && DECL_CONTEXT (decl) && context_die == comp_unit_die
+       && debug_info_level > DINFO_LEVEL_TERSE)
+     old_die = force_decl_die (decl);
+ 
    if (origin != NULL)
      {
        gcc_assert (!declaration || local_scope_p (context_die));
*************** gen_subprogram_die (tree decl, dw_die_re
*** 11579,11585 ****
  
  	     Note that force_decl_die() forces function declaration die. It is
  	     later reused to represent definition.  */
! 	    equate_decl_number_to_die (decl, subr_die);
  	}
      }
    else if (DECL_ABSTRACT (decl))
--- 11586,11592 ----
  
  	     Note that force_decl_die() forces function declaration die. It is
  	     later reused to represent definition.  */
! 	  equate_decl_number_to_die (decl, subr_die);
  	}
      }
    else if (DECL_ABSTRACT (decl))
*************** force_decl_die (tree decl)
*** 12790,12795 ****
--- 12797,12806 ----
        else
  	context_die = comp_unit_die;
  
+       decl_die = lookup_decl_die (decl);
+       if (decl_die)
+ 	return decl_die;
+ 
        switch (TREE_CODE (decl))
  	{
  	case FUNCTION_DECL:
*************** force_type_die (tree type)
*** 12840,12852 ****
      {
        dw_die_ref context_die;
        if (TYPE_CONTEXT (type))
! 	if (TYPE_P (TYPE_CONTEXT (type)))
! 	  context_die = force_type_die (TYPE_CONTEXT (type));
! 	else
! 	  context_die = force_decl_die (TYPE_CONTEXT (type));
        else
  	context_die = comp_unit_die;
  
        gen_type_die (type, context_die);
        type_die = lookup_type_die (type);
        gcc_assert (type_die);
--- 12851,12868 ----
      {
        dw_die_ref context_die;
        if (TYPE_CONTEXT (type))
! 	{
! 	  if (TYPE_P (TYPE_CONTEXT (type)))
! 	    context_die = force_type_die (TYPE_CONTEXT (type));
! 	  else
! 	    context_die = force_decl_die (TYPE_CONTEXT (type));
! 	}
        else
  	context_die = comp_unit_die;
  
+       type_die = lookup_type_die (type);
+       if (type_die)
+ 	return type_die;
        gen_type_die (type, context_die);
        type_die = lookup_type_die (type);
        gcc_assert (type_die);

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