]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/packed.rs
Rollup merge of #39604 - est31:i128_tests, r=alexcrichton
[rust.git] / src / test / codegen / packed.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -C no-prepopulate-passes
12
13 #![crate_type = "lib"]
14
15 #[repr(packed)]
16 pub struct Packed {
17     dealign: u8,
18     data: u32
19 }
20
21 // CHECK-LABEL: @write_pkd
22 #[no_mangle]
23 pub fn write_pkd(pkd: &mut Packed) -> u32 {
24 // CHECK: %{{.*}} = load i32, i32* %{{.*}}, align 1
25 // CHECK: store i32 42, i32* %{{.*}}, align 1
26     let result = pkd.data;
27     pkd.data = 42;
28     result
29 }