about summary refs log tree commit diff
path: root/tests/ui/asm/cfg-parse-error.rs
blob: 9b79d16a76ddade4f8ff3145b9d1c1b1402a454a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//@ needs-asm-support
#![feature(asm_cfg)]

use std::arch::asm;

fn main() {
    unsafe {
        asm!(
            "",
            #[cfg(false)]
            clobber_abi("C"),
            #[cfg(false)]
            options(att_syntax),
            #[cfg(false)]
            a = out(reg) x,
            "",
            //~^ ERROR expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""`
        );
        asm!(
            #[cfg(false)]
            "",
            #[cfg(false)]
            const {
                5
            },
            "",
            //~^ ERROR expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""`
        );

        asm!(
            #[cfg_attr(true, cfg(false))]
            const {
                5
            },
            "",
        );

        // This is not accepted because `a = out(reg) x` is not a valid expression.
        asm!(
            #[cfg(false)]
            a = out(reg) x, //~ ERROR expected token: `,`
            "",
        );

        // For now, any non-cfg attributes are rejected
        asm!(
            #[rustfmt::skip] //~ ERROR this attribute is not supported on assembly
            "",
        );

        // For now, any non-cfg attributes are rejected
        asm!(
            #![rustfmt::skip] //~ ERROR an inner attribute is not permitted in this context
            "",
        );
    }
}