I don't know the rules surrounding the expansion of block expressions in declarative macros and why inner attributes are problematic in that context. But as a workaround you can use inner attributes in a block expression wrapped in another block expression passed to the macro:
mymacro!({{
#![allow(dead_code)]
//#![warn(unused_variables)]
let x = 10;
println!("{}", x);
}});