summaryrefslogtreecommitdiffstats
path: root/tests/ui/cmse-nonsecure
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/cmse-nonsecure
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/cmse-nonsecure')
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs11
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr12
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs24
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs27
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr4
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs8
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr9
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs10
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr11
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs11
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr19
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs9
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.stderr11
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs16
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs16
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.stderr4
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs10
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.stderr9
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.rs13
-rw-r--r--tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.stderr9
20 files changed, 243 insertions, 0 deletions
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs
new file mode 100644
index 000000000..e05dbf3bb
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs
@@ -0,0 +1,11 @@
+// gate-test-abi_c_cmse_nonsecure_call
+fn main() {
+ let non_secure_function = unsafe {
+ core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>(
+ //~^ ERROR [E0658]
+ 0x10000004,
+ )
+ };
+ let mut toto = 5;
+ toto += non_secure_function(toto, 2, 3, 5);
+}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr
new file mode 100644
index 000000000..ed8e16899
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr
@@ -0,0 +1,12 @@
+error[E0658]: C-cmse-nonsecure-call ABI is experimental and subject to change
+ --> $DIR/gate_test.rs:4:46
+ |
+LL | core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>(
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #81391 <https://github.com/rust-lang/rust/issues/81391> for more information
+ = help: add `#![feature(abi_c_cmse_nonsecure_call)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs
new file mode 100644
index 000000000..bbc039bdf
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs
@@ -0,0 +1,24 @@
+// build-pass
+// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
+// needs-llvm-components: arm
+#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
+#![no_core]
+#[lang="sized"]
+pub trait Sized { }
+#[lang="copy"]
+pub trait Copy { }
+impl Copy for u32 {}
+
+extern "rust-intrinsic" {
+ pub fn transmute<T, U>(e: T) -> U;
+}
+
+#[no_mangle]
+pub fn test(a: u32, b: u32, c: u32, d: u32) -> u32 {
+ let non_secure_function = unsafe {
+ transmute::<usize, extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u32>(
+ 0x10000004,
+ )
+ };
+ non_secure_function(a, b, c, d)
+}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs
new file mode 100644
index 000000000..b8112b20a
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs
@@ -0,0 +1,27 @@
+// build-fail
+// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
+// needs-llvm-components: arm
+#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
+#![no_core]
+#[lang="sized"]
+pub trait Sized { }
+#[lang="copy"]
+pub trait Copy { }
+impl Copy for u32 {}
+
+extern "rust-intrinsic" {
+ pub fn transmute<T, U>(e: T) -> U;
+}
+
+#[no_mangle]
+pub fn test(a: u32, b: u32, c: u32, d: u32, e: u32) -> u32 {
+ let non_secure_function = unsafe {
+ transmute::<
+ usize,
+ extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32>
+ (
+ 0x10000004,
+ )
+ };
+ non_secure_function(a, b, c, d, e)
+}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr
new file mode 100644
index 000000000..372300787
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr
@@ -0,0 +1,4 @@
+error: <unknown>:0:0: in function test i32 (i32, i32, i32, i32, i32): call to non-secure function would require passing arguments on stack
+
+error: aborting due to previous error
+
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs
new file mode 100644
index 000000000..f32b37090
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs
@@ -0,0 +1,8 @@
+// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
+// needs-llvm-components: arm
+#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)]
+#![no_core]
+#[lang="sized"]
+trait Sized { }
+
+pub extern "C-cmse-nonsecure-call" fn test() {} //~ ERROR [E0781]
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr
new file mode 100644
index 000000000..08b763b26
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr
@@ -0,0 +1,9 @@
+error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers
+ --> $DIR/wrong-abi-location-1.rs:8:1
+ |
+LL | pub extern "C-cmse-nonsecure-call" fn test() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0781`.
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs
new file mode 100644
index 000000000..6f8bb24aa
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs
@@ -0,0 +1,10 @@
+// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
+// needs-llvm-components: arm
+#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)]
+#![no_core]
+#[lang="sized"]
+trait Sized { }
+
+extern "C-cmse-nonsecure-call" { //~ ERROR [E0781]
+ fn test();
+}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr
new file mode 100644
index 000000000..3ade9891e
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr
@@ -0,0 +1,11 @@
+error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers
+ --> $DIR/wrong-abi-location-2.rs:8:1
+ |
+LL | / extern "C-cmse-nonsecure-call" {
+LL | | fn test();
+LL | | }
+ | |_^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0781`.
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs
new file mode 100644
index 000000000..02d5f20fe
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs
@@ -0,0 +1,11 @@
+// gate-test-cmse_nonsecure_entry
+
+#[no_mangle]
+#[cmse_nonsecure_entry]
+//~^ ERROR [E0775]
+//~| ERROR [E0658]
+pub extern "C" fn entry_function(input: u32) -> u32 {
+ input + 6
+}
+
+fn main() {}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr
new file mode 100644
index 000000000..75a29b317
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr
@@ -0,0 +1,19 @@
+error[E0658]: the `#[cmse_nonsecure_entry]` attribute is an experimental feature
+ --> $DIR/gate_test.rs:4:1
+ |
+LL | #[cmse_nonsecure_entry]
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #75835 <https://github.com/rust-lang/rust/issues/75835> for more information
+ = help: add `#![feature(cmse_nonsecure_entry)]` to the crate attributes to enable
+
+error[E0775]: `#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension
+ --> $DIR/gate_test.rs:4:1
+ |
+LL | #[cmse_nonsecure_entry]
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0658, E0775.
+For more information about an error, try `rustc --explain E0658`.
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs
new file mode 100644
index 000000000..a839406cd
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs
@@ -0,0 +1,9 @@
+// Regression test for the ICE described in #83475.
+
+#![crate_type="lib"]
+
+#![feature(cmse_nonsecure_entry)]
+#[cmse_nonsecure_entry]
+//~^ ERROR: attribute should be applied to a function definition
+struct XEmpty2;
+//~^ NOTE: not a function definition
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.stderr
new file mode 100644
index 000000000..426d82d8d
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.stderr
@@ -0,0 +1,11 @@
+error: attribute should be applied to a function definition
+ --> $DIR/issue-83475.rs:6:1
+ |
+LL | #[cmse_nonsecure_entry]
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | struct XEmpty2;
+ | --------------- not a function definition
+
+error: aborting due to previous error
+
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs
new file mode 100644
index 000000000..5591a8a58
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs
@@ -0,0 +1,16 @@
+// build-pass
+// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
+// needs-llvm-components: arm
+#![feature(cmse_nonsecure_entry, no_core, lang_items)]
+#![no_core]
+#[lang="sized"]
+trait Sized { }
+#[lang="copy"]
+trait Copy { }
+impl Copy for u32 {}
+
+#[no_mangle]
+#[cmse_nonsecure_entry]
+pub extern "C" fn entry_function(_: u32, _: u32, _: u32, d: u32) -> u32 {
+ d
+}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs
new file mode 100644
index 000000000..39b41dac4
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs
@@ -0,0 +1,16 @@
+// build-fail
+// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
+// needs-llvm-components: arm
+#![feature(cmse_nonsecure_entry, no_core, lang_items)]
+#![no_core]
+#[lang="sized"]
+trait Sized { }
+#[lang="copy"]
+trait Copy { }
+impl Copy for u32 {}
+
+#[no_mangle]
+#[cmse_nonsecure_entry]
+pub extern "C" fn entry_function(_: u32, _: u32, _: u32, _: u32, e: u32) -> u32 {
+ e
+}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.stderr
new file mode 100644
index 000000000..1054c2665
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.stderr
@@ -0,0 +1,4 @@
+error: <unknown>:0:0: in function entry_function i32 (i32, i32, i32, i32, i32): secure entry function requires arguments on stack
+
+error: aborting due to previous error
+
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs
new file mode 100644
index 000000000..3783e2794
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs
@@ -0,0 +1,10 @@
+// ignore-thumbv8m.main-none-eabi
+#![feature(cmse_nonsecure_entry)]
+
+#[no_mangle]
+#[cmse_nonsecure_entry] //~ ERROR [E0775]
+pub extern "C" fn entry_function(input: u32) -> u32 {
+ input + 6
+}
+
+fn main() {}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.stderr
new file mode 100644
index 000000000..7e8862f9a
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.stderr
@@ -0,0 +1,9 @@
+error[E0775]: `#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension
+ --> $DIR/trustzone-only.rs:5:1
+ |
+LL | #[cmse_nonsecure_entry]
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0775`.
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.rs
new file mode 100644
index 000000000..6320d2963
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.rs
@@ -0,0 +1,13 @@
+// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
+// needs-llvm-components: arm
+#![feature(cmse_nonsecure_entry, no_core, lang_items)]
+#![no_core]
+#[lang="sized"]
+trait Sized { }
+
+#[no_mangle]
+#[cmse_nonsecure_entry]
+//~^ ERROR `#[cmse_nonsecure_entry]` requires C ABI [E0776]
+pub fn entry_function(_: u32, _: u32, _: u32, d: u32) -> u32 {
+ d
+}
diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.stderr
new file mode 100644
index 000000000..36d76c967
--- /dev/null
+++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.stderr
@@ -0,0 +1,9 @@
+error[E0776]: `#[cmse_nonsecure_entry]` requires C ABI
+ --> $DIR/wrong-abi.rs:9:1
+ |
+LL | #[cmse_nonsecure_entry]
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0776`.