properly handle #[cfg] (conditional compilation) on resources

This commit is contained in:
Jorge Aparicio 2018-12-16 18:37:36 +01:00
parent 9757c33b00
commit 4345c10596
8 changed files with 362 additions and 77 deletions

49
tests/cpass/cfg.rs Normal file
View file

@ -0,0 +1,49 @@
//! Compile-pass test that checks that `#[cfg]` attributes are respected
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate lm3s6965;
extern crate panic_semihosting;
extern crate rtfm;
use rtfm::app;
#[app(device = lm3s6965)]
const APP: () = {
#[cfg(never)]
static mut FOO: u32 = 0;
#[init]
fn init() {
#[cfg(never)]
static mut BAR: u32 = 0;
}
#[idle]
fn idle() -> ! {
#[cfg(never)]
static mut BAR: u32 = 0;
loop {}
}
#[task(resources = [FOO])]
fn foo() {
#[cfg(never)]
static mut BAR: u32 = 0;
}
#[task(priority = 3, resources = [FOO])]
fn bar() {
#[cfg(never)]
static mut BAR: u32 = 0;
}
extern "C" {
fn UART0();
fn UART1();
}
};