From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2109) id 613603858C1F; Tue, 22 Nov 2022 12:43:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 613603858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669120987; bh=urhWCxZFJwTpmRG+5G6LUIXs70VGkV3kPbIzMUrTPIM=; h=From:To:Subject:Date:From; b=Hb0pbGeQjxAbfcmuJWRwaPJQUWYPZYXX7/yVt8r2s026Ktf71MLRdamIrMKi1wnuY artEprUcYf3I0+W6Gp4CPAneDrd2HmCw98NZVAoQ1sP1ZR5kbb/ZbFODZVbP0+FhZN 4KaSLEWsUCd2XrWoqtcsXcJzy7eznrit9Wsq08jU= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Stam Markianos-Wright To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] morello testsuite: Fix up global-constants.c test X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: d11f8e14fe75fd148e42464cc0b489e2de8b7574 X-Git-Newrev: 535b95325abf4d9b6f0fe3fed29874e42b8ac4d0 Message-Id: <20221122124307.613603858C1F@sourceware.org> Date: Tue, 22 Nov 2022 12:43:07 +0000 (GMT) List-Id: https://gcc.gnu.org/g:535b95325abf4d9b6f0fe3fed29874e42b8ac4d0 commit 535b95325abf4d9b6f0fe3fed29874e42b8ac4d0 Author: Alex Coplan Date: Tue Nov 8 14:04:04 2022 +0000 morello testsuite: Fix up global-constants.c test This test had the construct: char * __capability stringval = "abcdef"; which is rejected when compiling for hybrid with: error: initializer element is not valid for capability type since the RHS has non-capability type, the LHS has capability type, and GCC (unlike CHERI LLVM) doesn't allow the __capability type information to flow from the LHS to the RHS here. so to fix the test, we drop the __capability annotation from this variable. We also adjust a dg-warning check that is expected not to fire on hybrid. Finally, we drop some unnecessary defines and make some other minor cleanups. Overall the changes allow the test to pass in all configruations. Diff: --- .../gcc.target/aarch64/morello/global-constants.c | 27 ++++++---------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/gcc/testsuite/gcc.target/aarch64/morello/global-constants.c b/gcc/testsuite/gcc.target/aarch64/morello/global-constants.c index 624e6742095..f015ed60720 100644 --- a/gcc/testsuite/gcc.target/aarch64/morello/global-constants.c +++ b/gcc/testsuite/gcc.target/aarch64/morello/global-constants.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* Choose a string so that the value of it can't be folded away when generating the TREE expression (something like a cast of 10 gets folded automatically). - + Then cast it to an unsigned long long, before casting it back to a pointer. Before introducing capabilities this would work, but after we get an error complaining that the initializer element is not constant. */ @@ -11,37 +11,24 @@ __builtin_abort(); -#ifndef __GCC_ARM_CAPABILITY_ANY -#define __capability -#define __uintcap_t unsigned long long -#endif -/* TODO Need to have some sort of a check against Hybrid when requiring this - * warning. - * Will cross that hurdle when I get to it. */ -int *x = (int*)(unsigned long long)"abcde"; /* { dg-warning "cast from provenance-free integer type to pointer type" "" { target *-*-* } } */ -char * __capability stringval = "abcdef"; +int *x = (int*)(unsigned long long)"abcde"; /* { dg-warning "cast from provenance-free integer type to pointer type" "" { target {! cheri_capability_hybrid} } } */ +char *stringval = "abcdef"; char * basicstring = "abcdefg"; -__uintcap_t ucap = "abcdefgh"; /* { dg-warning "makes integer from pointer without a cast" "" { target *-*-* } } */ -__uintcap_t ucap2 = 100; +unsigned __intcap ucap = "abcdefgh"; /* { dg-warning "makes integer from pointer without a cast" "" { target *-*-* } } */ +unsigned __intcap ucap2 = 100; int main() { assert (x); assert (stringval); assert (basicstring); - /* assert (ucap); - assert (ucap2 == 100); - assert (((char*)ucap)[0] == 'a' && ((char*)ucap)[7] == 'h' - && ((char*)ucap)[8] == '\0'); */ #ifndef __CHERI_PURE_CAPABILITY__ + /* The capability 'x' will be invalid on purecap. */ assert (((char*)x)[0] == 'a' && ((char*)x)[4] == 'e' && ((char*)x)[5] == '\0'); +#endif assert (basicstring[0] == 'a' && basicstring[6] == 'g' && basicstring[7] == '\0'); assert (stringval[0] == 'a' && stringval[5] == 'f' && stringval[6] == '\0'); -#endif return 0; } - -/* TODO Execution test to check everything works properly (i.e. all the - globals are accessible, and have the contents they should). */