public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] c: Handle conversion from bool to capability pointer
@ 2022-07-12 10:37 Alex Coplan
0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2022-07-12 10:37 UTC (permalink / raw)
To: gcc-cvs
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 } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-12 10:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 10:37 [gcc(refs/vendors/ARM/heads/morello)] c: Handle conversion from bool to capability pointer Alex Coplan
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).