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)] c: Handle conversion from bool to capability pointer
Date: Tue, 12 Jul 2022 10:37:09 +0000 (GMT)	[thread overview]
Message-ID: <20220712103709.7817B3857B9D@sourceware.org> (raw)

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

commit b0ce8fb18b6a659408c3a28c661731f1c433558b
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Thu Jul 7 11:54:12 2022 +0100

    c: Handle conversion from bool to capability pointer
    
    We were checking explicitly for INTEGER_TYPE, relax this to
    INTEGRAL_TYPE_P instead to also handle converting from booleans and
    enums to capability pointers.
    
    gcc/c/ChangeLog:
    
            * c-convert.c (convert): Handle converting from enums and
            booleans to capability pointers.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/morello/conv-bool-ptr.c: New test.

Diff:
---
 gcc/c/c-convert.c                                        | 2 +-
 gcc/testsuite/gcc.target/aarch64/morello/conv-bool-ptr.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/c/c-convert.c b/gcc/c/c-convert.c
index 3f763e8aaed..7b8951f1294 100644
--- a/gcc/c/c-convert.c
+++ b/gcc/c/c-convert.c
@@ -143,7 +143,7 @@ convert (tree type, tree expr)
 
     case POINTER_TYPE:
     case REFERENCE_TYPE:
-      if (capability_type_p (type) && TREE_CODE (TREE_TYPE (e)) == INTEGER_TYPE)
+      if (capability_type_p (type) && INTEGRAL_TYPE_P (TREE_TYPE (e)))
 	ret = c_common_cap_from_noncap (type, e);
       else if (capability_type_p (type) && !capability_type_p (TREE_TYPE (e))
 	       && POINTER_TYPE_P (TREE_TYPE (e)))
diff --git a/gcc/testsuite/gcc.target/aarch64/morello/conv-bool-ptr.c b/gcc/testsuite/gcc.target/aarch64/morello/conv-bool-ptr.c
new file mode 100644
index 00000000000..09d531a2c77
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/morello/conv-bool-ptr.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+void *f(_Bool b) { return (void *)b; }
+/* { dg-warning "cast from provenance-free integer type to pointer type" "" { target *-*-* } .-1 } */


                 reply	other threads:[~2022-07-12 10:37 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=20220712103709.7817B3857B9D@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).