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