From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7810) id 7817B3857B9D; Tue, 12 Jul 2022 10:37:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7817B3857B9D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alex Coplan To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] c: Handle conversion from bool to capability pointer X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: 9f4ac6c51abdd6a51dda683f53ee19b766661c7e X-Git-Newrev: b0ce8fb18b6a659408c3a28c661731f1c433558b Message-Id: <20220712103709.7817B3857B9D@sourceware.org> Date: Tue, 12 Jul 2022 10:37:09 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2022 10:37:09 -0000 https://gcc.gnu.org/g:b0ce8fb18b6a659408c3a28c661731f1c433558b commit b0ce8fb18b6a659408c3a28c661731f1c433558b Author: Alex Coplan 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 } */