about summary refs log tree commit diff
path: root/tests/ui/static/static-align.rs
blob: 93241db09f949181f6b0f47918b214ad099dd1cf (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
//@ run-pass
#![feature(static_align)]

#[rustc_align_static(64)]
static A: u8 = 0;

#[rustc_align_static(64)]
static B: u8 = 0;

#[rustc_align_static(128)]
#[no_mangle]
static EXPORTED: u64 = 0;

unsafe extern "C" {
    #[rustc_align_static(128)]
    #[link_name = "EXPORTED"]
    static C: u64;
}

fn main() {
    assert!(core::ptr::from_ref(&A).addr().is_multiple_of(64));
    assert!(core::ptr::from_ref(&B).addr().is_multiple_of(64));

    assert!(core::ptr::from_ref(&EXPORTED).addr().is_multiple_of(128));
    unsafe { assert!(core::ptr::from_ref(&C).addr().is_multiple_of(128)) };
}