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]

Re: Fix PR34895: ICE in dwarf2out.c


On Jan 22, 2008 7:49 PM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> [literally from the bugzilla comment]
>
> The problem is, that gen_type_die() generates a DIE only for the main
> variant of the given type.  But lookup_type_die looks in the type itself.
> In the example the type in question is "const A", for which no DIE exists
> already. So force_type_die() goes into the if(), calls gen_type_die which
> generated a DIE for "A" (in fact that already exists, so it just returns).
> But a DIE for "const A" still doesn't exist of course.  The example can be
> made to compile to force such existence, e.g. by adding a member to "A":
>
>   struct A {
>     ...
>     void cmem() const;
>   };
>
> There are two ways of fixing this:
> 1) making sure, that "const A" (the tree node) refers to the DIE for "A",
>    i.e. losing the qualifiers.  One could ensure this in either
>    force_type_die or even gen_type_die by calling
>    equate_type_number_to_die.
> 2) ensure that force_type_die() really creates a DIE which reflects type
>    (and not just the main variant).
>
> With the above test one can see, that the intention was, that the
> AT_import decl really comes inside the DIE for "const A".  So, that speaks
> for option 2. This is also the natural choice as a function named
> "force_type_die" surely should generate a DIE for that very type and not
> some other variant of it.
>
> The below patch would implement this.
>
> Okay for trunk if regstrapping passes?  (I would include the testcase from
> bugzilla)

Ok.

Thanks,
Richard.

>
> Ciao,
> Michael.
> --
>         PR debug/34895
>         * dwarf2out.c (force_type_die): Use modified_type_die instead of
>         gen_type_die.
>
>         * g++.dg/debug/pr34895.cc: New testcase.
>
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c     (revision 131712)
> +++ gcc/dwarf2out.c     (working copy)
> @@ -13736,11 +13736,8 @@ force_type_die (tree 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);
> +      type_die = modified_type_die (type, TYPE_READONLY (type),
> +                                   TYPE_VOLATILE (type), context_die);
>        gcc_assert (type_die);
>      }
>    return type_die;
>


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