public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] morello testsuite: Fix up global-constants.c test
@ 2022-11-14 13:24 Alex Coplan
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Coplan @ 2022-11-14 13:24 UTC (permalink / raw)
  To: gcc-cvs

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).  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/vendors/ARM/heads/morello)] morello testsuite: Fix up global-constants.c test
@ 2022-11-22 12:43 Stam Markianos-Wright
  0 siblings, 0 replies; 2+ messages in thread
From: Stam Markianos-Wright @ 2022-11-22 12:43 UTC (permalink / raw)
  To: gcc-cvs

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).  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-22 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 13:24 [gcc(refs/vendors/ARM/heads/morello)] morello testsuite: Fix up global-constants.c test Alex Coplan
2022-11-22 12:43 Stam Markianos-Wright

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).