diff options
author | Prajwal S N <prajwalnadig21@gmail.com> | 2022-12-31 12:49:02 +0530 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-04-06 10:47:16 +0200 |
commit | 776ff053800ad989564b0b3c2904fb072abaf422 (patch) | |
tree | 3d0a62e12dbe4ee8cb086f0693e5ff5434b80cf0 /gcc/testsuite/rust | |
parent | f66b135d0b55fda15dfce927b14ab9c89b9fb6a7 (diff) | |
download | gcc-776ff053800ad989564b0b3c2904fb072abaf422.zip gcc-776ff053800ad989564b0b3c2904fb072abaf422.tar.gz gcc-776ff053800ad989564b0b3c2904fb072abaf422.tar.bz2 |
gccrs: unsafe: check use of `target_feature` attribute
The `target_feature` attribute is for conditional compilation and may or
may not compile on all platforms. Using it requires an unsafe function
or block.
gcc/rust/ChangeLog:
* checks/errors/rust-unsafe-checker.cc (check_target_attr): New function.
(UnsafeChecker::check_function_attr): Call into `check_target_attr`.
(UnsafeChecker::visit): Check for target_feature attributes.
* checks/errors/rust-unsafe-checker.h: Add declarations.
* util/rust-attributes.cc: Add attribute.
gcc/testsuite/ChangeLog:
* rust/compile/unsafe11.rs: New test.
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r-- | gcc/testsuite/rust/compile/unsafe11.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/unsafe11.rs b/gcc/testsuite/rust/compile/unsafe11.rs new file mode 100644 index 0000000..c87902f --- /dev/null +++ b/gcc/testsuite/rust/compile/unsafe11.rs @@ -0,0 +1,8 @@ +#[target_feature(sse)] +fn foo() { + let a: usize = 0; +} + +fn main() { + foo() // { dg-error "requires unsafe function or block" } +} |