-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend the __capability qualifier tests for typeof() and decltype()
This exposed a new crash: #710
- Loading branch information
1 parent
40b9240
commit 4fa1628
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 25 additions & 2 deletions
27
clang/test/Sema/cheri/cheri-capability-qualifier-declspec.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
// RUN: %cheri_cc1 -o - %s -fsyntax-only -verify | ||
// RUN: %cheri_cc1 %s -fsyntax-only -verify | ||
// expected-no-diagnostics | ||
|
||
void * __capability test_typeof(void *p) { | ||
void *__capability test_typeof(void *p) { | ||
__typeof__(p) __capability c = (__cheri_tocap __typeof__(p) __capability)p; | ||
_Static_assert(__builtin_types_compatible_p(typeof(c), void *__capability), ""); | ||
__capability __typeof__(p) c2 = (__cheri_tocap __capability __typeof__(p))p; | ||
_Static_assert(__builtin_types_compatible_p(typeof(c2), void *__capability), ""); | ||
__capability __typeof__(p) *__capability c3 = (__cheri_tocap __capability __typeof__(p) *__capability)p; | ||
_Static_assert(__builtin_types_compatible_p(typeof(c3), void *__capability *__capability), ""); | ||
return c; | ||
} | ||
|
||
static int *global_intptr = 0; | ||
static __capability typeof(global_intptr) global_intcap = 0; | ||
_Static_assert(__builtin_types_compatible_p(typeof(global_intptr), int *), ""); | ||
_Static_assert(__builtin_types_compatible_p(typeof(global_intcap), int *__capability), ""); | ||
|
||
/// Crash reproducer for https://github.com/CTSRD-CHERI/llvm-project/issues/710 | ||
// RUN: not --crash %cheri_cc1 %s -fsyntax-only -verify -DCRASH | ||
// REQUIRES: asserts | ||
#ifdef CRASH | ||
struct s { | ||
int i; | ||
}; | ||
static struct s *global_sptr = 0; | ||
static __capability typeof(global_sptr) global_scap = 0; | ||
_Static_assert(__builtin_types_compatible_p(typeof(global_sptr), struct s *), ""); | ||
_Static_assert(__builtin_types_compatible_p(typeof(global_scap), struct s *__capability), ""); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters