public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Uecker <uecker@tugraz.at>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
	gcc@gcc.gnu.org, Joseph Myers <josmyers@redhat.com>
Subject: Re: check_qualified_type
Date: Mon, 17 Jun 2024 15:53:41 +0200	[thread overview]
Message-ID: <b6cdf02cd2b6360049db6b8bea1bbd5b646766b1.camel@tugraz.at> (raw)
In-Reply-To: <ZnA82AuBz/vM3Jov@tucnak>

Am Montag, dem 17.06.2024 um 15:40 +0200 schrieb Jakub Jelinek:
> On Mon, Jun 17, 2024 at 03:33:05PM +0200, Martin Uecker wrote:
> > > I've done that and that was because build_qualified_type uses that
> > > predicate, where qualified types created by build_qualified_type have
> > > as TYPE_CANONICAL the qualified type of the main variant of the canonical
> > > type, while in all other cases TYPE_CANONICAL is just the main variant of
> > > the type.
> > > Guess we could also just do
> > >           if (TYPE_QUALS (x) == TYPE_QUALS (t))
> > >             TYPE_CANONICAL (x) = TYPE_CANONICAL (t);
> > >           else if (TYPE_CANONICAL (t) != t
> > > 		   || TYPE_QUALS (x) != TYPE_QUALS (TYPE_CANONICAL (t)))
> > >             TYPE_CANONICAL (x)
> > >               = build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x));
> > >           else
> > >             TYPE_CANONICAL (x) = x;
> > > 
> > 
> > Ok, that works. I think the final "else" is then then impossible to reach
> > and can be eliminated as well, because if TYPE_CANONICAL (t) == t then 
> > TYPE_QUALS (x) == TYPE_QUALS (TYPE_CANONICAL (t)) is identical to
> > TYPE_QUALS (x) == TYPE_QUALS (t) which is the first case.
> 
> If c_update_type_canonical is only ever called for the main variants of the
> type and they always have !TYPE_QUALS (t), then yes.
> But if we rely on that, perhaps we should gcc_checking_assert that.
> So
>   gcc_checking_assert (t == TYPE_MAIN_VARIANT (t) && !TYPE_QUALS (t));
> or something similar at the start of the function.

It calls itself recursively on pointers to the type.  But to
me the third branch looks dead in any case, because the first
two cover all possibilities.

Martin

> Then we could also change the
>   for (tree x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
> to
>   for (tree x = t; x; x = TYPE_NEXT_VARIANT (x))
> and
> 	  if (TYPE_QUALS (x) == TYPE_QUALS (t))
> ...
> to
> 	  if (!TYPE_QUALS (x))
> 	    TYPE_CANONICAL (x) = TYPE_CANONICAL (t);
> 	  else
> 	    build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x));
> 





> 


  reply	other threads:[~2024-06-17 13:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-16 20:22 check_qualified_type Martin Uecker
2024-06-17  6:01 ` check_qualified_type Richard Biener
2024-06-17  6:31   ` check_qualified_type Martin Uecker
2024-06-17 12:42     ` check_qualified_type Richard Biener
2024-06-17 12:57       ` check_qualified_type Jakub Jelinek
2024-06-17 13:33         ` check_qualified_type Martin Uecker
2024-06-17 13:40           ` check_qualified_type Jakub Jelinek
2024-06-17 13:53             ` Martin Uecker [this message]
2024-06-17 14:01               ` check_qualified_type Jakub Jelinek
2024-06-17 16:01   ` check_qualified_type Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6cdf02cd2b6360049db6b8bea1bbd5b646766b1.camel@tugraz.at \
    --to=uecker@tugraz.at \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=josmyers@redhat.com \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).