Hi,

On Fri, Mar 16, 2012 at 05:14:38PM +0100, Martin Jambor wrote:
> On Mon, Mar 12, 2012 at 11:51:05AM +0100, Richard Guenther wrote:
> > On Thu, Mar 8, 2012 at 12:18 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> > > On Thu, Mar 08, 2012 at 12:06:46PM +0100, Martin Jambor wrote:
> > >>        /* For local statics lookup proper context die.  */
> > >> -      if (TREE_STATIC (decl) && decl_function_context (decl))
> > >> -     context_die = lookup_decl_die (DECL_CONTEXT (decl));
> > >> +      if (TREE_STATIC (decl) &&
> > >> +       (ctx_fndecl = decl_function_context (decl)) != NULL_TREE)
> > >> +     context_die = lookup_decl_die (ctx_fndecl);
> > >
> > > The formatting is wrong, && shouldn't be at the end of line.
> > > For the rest I'll defer to Jason, not sure what exactly we want to do 
> > > there.
> > > This hunk has been added by Honza:
> > 
> > I don't think the patch is right.  Suppose you have a function-local
> > class declaration with a static member.  Surely the context DIE
> > you want to use is still the class one, not the function one.
> 
> That is not what happens, though.  The problem is that we attempt to
> generate debug info for VMTs of classes defined within functions.  I
> have filed PR 52605 with a small testcase to track the issue.
> 
> I have not yet had a look at how this code treats (or should treat)
> static members of classes defined within a function.
> 

It turs out that local classes are not allowed to have static data
members.  GCC will compile such class with -fpermissive but then the
linker fails with an undefined reference because the data member is
not defined anywhere and I did not manage to figure out or google how
to define it.  Therefore I think this is not an issue.

It seems to me that dwarf2out_decl was intended to supply either
comp_unit_die or a function decl die as the context to gen_decl_die
(which detects memberr-ness by decl_class_context) and thus I still
tend to think my patch (with adjusted formatting) is a correct and
simple fix.  Nevertheless I'll be happy to learn more if I am wrong.

Martin

Reply via email to