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)] morello testsuite: Fix up global-constants.c test
Date: Mon, 14 Nov 2022 13:24:21 +0000 (GMT)	[thread overview]
Message-ID: <20221114132421.2ED453835791@sourceware.org> (raw)

https://gcc.gnu.org/g:535b95325abf4d9b6f0fe3fed29874e42b8ac4d0

commit 535b95325abf4d9b6f0fe3fed29874e42b8ac4d0
Author: Alex Coplan <alex.coplan@arm.com>
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).  */

             reply	other threads:[~2022-11-14 13:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 13:24 Alex Coplan [this message]
2022-11-22 12:43 Stam Markianos-Wright

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=20221114132421.2ED453835791@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).