diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cfail/early-return-2.rs | 29 | ||||
| -rw-r--r-- | tests/cfail/early-return.rs | 32 |
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/cfail/early-return-2.rs b/tests/cfail/early-return-2.rs new file mode 100644 index 0000000..bf867e0 --- /dev/null +++ b/tests/cfail/early-return-2.rs @@ -0,0 +1,29 @@ +#![no_main] +#![no_std] + +extern crate lm3s6965; +extern crate panic_halt; +extern crate rtfm; + +use rtfm::app; + +#[app(device = lm3s6965)] +const APP: () = { + static mut UNINITIALIZED: bool = (); + + #[init] + fn init() { + if false { + return; //~ ERROR `init` is *not* allowed to early return + } + + UNINITIALIZED = true; + } + + #[interrupt(resources = [UNINITIALIZED])] + fn UART0() { + if resources.UNINITIALIZED { + // UB + } + } +}; diff --git a/tests/cfail/early-return.rs b/tests/cfail/early-return.rs new file mode 100644 index 0000000..fb695aa --- /dev/null +++ b/tests/cfail/early-return.rs @@ -0,0 +1,32 @@ +#![no_main] +#![no_std] + +extern crate lm3s6965; +extern crate panic_halt; +extern crate rtfm; + +use rtfm::app; + +#[app(device = lm3s6965)] +const APP: () = { + static mut UNINITIALIZED: bool = (); + + #[init] + fn init() { + let x = || { + // this is OK + return 0; + }; + + return; //~ ERROR `init` is *not* allowed to early return + + UNINITIALIZED = true; + } + + #[interrupt(resources = [UNINITIALIZED])] + fn UART0() { + if resources.UNINITIALIZED { + // UB + } + } +}; |
