On Thu, 23 May 2024, Ian Lance Taylor wrote:

> On Thu, May 23, 2024 at 2:48 PM Martin Uecker <uec...@tugraz.at> wrote:
> >
> > Am Donnerstag, dem 23.05.2024 um 14:30 -0700 schrieb Ian Lance Taylor:
> > > On Thu, May 23, 2024 at 2:00 PM Joseph Myers <josmy...@redhat.com> wrote:
> > > >
> > > > On Tue, 21 May 2024, Martin Uecker wrote:
> > > > >
> > > > >     C: allow aliasing of compatible types derived from enumeral types 
> > > > > [PR115157]
> > > > >
> > > > >     Aliasing of enumeral types with the underlying integer is now 
> > > > > allowed
> > > > >     by setting the aliasing set to zero.  But this does not allow 
> > > > > aliasing
> > > > >     of derived types which are compatible as required by ISO C.  
> > > > > Instead,
> > > > >     initially set structural equality.  Then set TYPE_CANONICAL and 
> > > > > update
> > > > >     pointers and main variants when the type is completed (as done for
> > > > >     structures and unions in C23).
> > > > >
> > > > >     PR 115157
> > > > >
> > > > >     gcc/c/
> > > > >             * c-decl.cc (shadow_tag-warned,parse_xref_tag,start_enum,
> > > > >             finish_enum): Set SET_TYPE_STRUCTURAL_EQUALITY / 
> > > > > TYPE_CANONICAL.
> > > > >             * c-obj-common.cc (get_alias_set): Remove special case.
> > > > >             (get_aka_type): Add special case.
> > > > >
> > > > >     gcc/
> > > > >             * godump.cc (go_output_typedef): use TYPE_MAIN_VARIANT 
> > > > > instead
> > > > >             of TYPE_CANONICAL.
> > > > >
> > > > >     gcc/testsuite/
> > > > >             * gcc.dg/enum-alias-1.c: New test.
> > > > >             * gcc.dg/enum-alias-2.c: New test.
> > > > >             * gcc.dg/enum-alias-3.c: New test.
> > > >
> > > > OK, in the absence of objections on middle-end or Go grounds within the
> > > > next week.
> > >
> > > The godump.cc patch is
> > >
> > >        && (TYPE_CANONICAL (TREE_TYPE (decl)) == NULL_TREE
> > >           || !container->decls_seen.contains
> > > -                                   (TYPE_CANONICAL (TREE_TYPE (decl)))))
> > > +                                   (TYPE_MAIN_VARIANT (TREE_TYPE 
> > > (decl)))))
> > >      {
> > >
> > > What is the problem you are seeing?
> >
> > Test failures in godump-1.c
> >
> > >
> > > This patch isn't right:
> > >
> > > 1) The code is saying if "X == NULL_TREE || !already_seen(X)".  This
> > > patch is changing the latter X but not the former.  They should be
> > > consistent.
> >
> > Maybe the X == NULL_TREE can be removed if we
> > add TYPE_MAIN_VARIANTs instead?
> 
> If TYPE_MAIN_VARIANT is never NULL_TREE, then I agree that the
> NULL_TREE test can be removed.

TYPE_MAIN_VARIANT is indeed never NULL_TREE.

Richard.

Reply via email to