]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/repr-packed-contains-align.rs
New upstream version 1.25.0+dfsg1
[rustc.git] / src / test / compile-fail / repr-packed-contains-align.rs
CommitLineData
32a655c1 1// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
223e47cc
LB
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.
3b2f2976 10#![feature(untagged_unions)]
cc61c64b 11#![allow(dead_code)]
223e47cc 12
cc61c64b 13#[repr(align(16))]
3b2f2976 14struct SA(i32);
223e47cc 15
3b2f2976
XL
16struct SB(SA);
17
18#[repr(align(16))]
19union UA {
20 i: i32
21}
22
23union UB {
24 a: UA
25}
26
27#[repr(packed)]
28struct SC(SA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
29
30#[repr(packed)]
31struct SD(SB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
32
33#[repr(packed)]
34struct SE(UA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
35
36#[repr(packed)]
37struct SF(UB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
38
39#[repr(packed)]
40union UC { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
41 a: UA
42}
43
44#[repr(packed)]
45union UD { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
46 n: UB
47}
b039eaaf 48
cc61c64b 49#[repr(packed)]
3b2f2976
XL
50union UE { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
51 a: SA
52}
cc61c64b
XL
53
54#[repr(packed)]
3b2f2976
XL
55union UF { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
56 n: SB
57}
cc61c64b
XL
58
59fn main() {}