> > 
> > Why not just make all anonymous types their own canonical type?
> > (of course considering type variants)
> 
> If C++ FE sets canonical type always to main variant, it should work.
> Is it always the case? I noticed you do this for variadic types.
> I tought there is reason why canonical types differ from main variants
> and the way canonical types are built in FE seems more complex too, than
> just setting CANONICAL=MAIN_VARIANT
> > 
> > >   2) update canonical type hash so it can deal with types that already 
> > > have
> > >      canonical type set.
> > >      I insert even anonymous types there because I am not able to get rid
> > >      of cases where non-anonmous type explicitly mentions anonymous. 
> > > Consider:
> > >       namespace {
> > >       struct B {};
> > >       }
> > >       struct A
> > >       {
> > >   void t(B);
> > >   void t2();
> > >       };
> > >       void
> > >       A::t(B)
> > >       {
> > >       }
> > >       void
> > >       A::t2()
> > >       {
> > >       }
> > >      Here we end up having type of method T non-anonymous but it builds 
> > > from B that
> > >      is anonymous.
> > 
> > But that makes B non-anonymous as well?  How is A::t mangled?  Consider 
> > also the simpler case
> > 
> > struct A { struct B b; };
> 
> Yep, A seems to be not anonymous and mangled as A.  I think it is ODR 
> violation
> to declare such type in more than one compilation unit (and we will warn on
> it). We can make it anonymous, but I think it is C++ FE to do so.

If I update my testcase to also have struct B b as a field I get:
        .type   _ZN1A2t2Ev, @function
_ZN1A2t2Ev:
.LFB1:
        .cfi_startproc
        rep ret
        .cfi_endproc

I.e. a::t is static (based on its anonymous namespace argument B) while a::t2 
is normal
externally visible method for type mangled as A.

Reply via email to