public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alex Coplan <acoplan@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/ARM/heads/morello)] cp: Use same_type_p in cp_build_binary_op for intcap check
Date: Mon, 13 Jun 2022 10:13:56 +0000 (GMT)	[thread overview]
Message-ID: <20220613101356.12B2F3853577@sourceware.org> (raw)

https://gcc.gnu.org/g:b479d8363d3f0387747de0d039ad9870d3908624

commit b479d8363d3f0387747de0d039ad9870d3908624
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Sat May 7 18:38:44 2022 +0100

    cp: Use same_type_p in cp_build_binary_op for intcap check
    
    This fixes an ICE seen with the following testcase (reduced from building
    purecap libstdc++):
    
    typedef long T;
    T sz;
    __intcap f() {
      return sz + (__intcap)f;
    }
    
    the issue here is that we have two different non-capability types: T and
    long are both really the same type, but are represented by different
    nodes in the IR, so pointer equality fails us, and we ICE in
    cp_build_binary_op. Adjust the check to use same_type_p instead.
    
    gcc/cp/ChangeLog:
    
            * typeck.c (cp_build_binary_op): Use same_type_p to check the
            non-capability type of the final intcap type is the same type as
            the type we did the arithmetic in.

Diff:
---
 gcc/cp/typeck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 84fecd410cf..5bab85e412b 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5879,7 +5879,7 @@ cp_build_binary_op (const op_location_t &location,
 	{
 	  tree ic_type = cp_common_type (TREE_TYPE (intcap),
 					 TREE_TYPE (result));
-	  gcc_assert (TREE_TYPE (result) == noncapability_type (ic_type));
+	  gcc_assert (same_type_p (TREE_TYPE (result), noncapability_type (ic_type)));
 	  intcap = cp_convert (ic_type, intcap, complain);
 	  result = fold_build_replace_address_value_loc (location,
 							 intcap,


                 reply	other threads:[~2022-06-13 10:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220613101356.12B2F3853577@sourceware.org \
    --to=acoplan@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).