about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorCameron Hart <cameron.hart@gmail.com>2017-07-24 07:54:48 +1000
committerCameron Hart <cameron.hart@gmail.com>2017-07-24 07:54:48 +1000
commit5cccd6a9eeea380af4f8150b7afcdc9f15332abc (patch)
tree4a6bce2bb84bd7b7ae2bdf442c481942c48785e0 /src/test
parent200c4d041059dd233c2181ff0fd0997b08bdc755 (diff)
downloadrust-5cccd6a9eeea380af4f8150b7afcdc9f15332abc.tar.gz
rust-5cccd6a9eeea380af4f8150b7afcdc9f15332abc.zip
Apply packed and align restrictions to unions.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/conflicting-repr-hints.rs23
-rw-r--r--src/test/compile-fail/repr-packed-contains-align.rs44
2 files changed, 60 insertions, 7 deletions
diff --git a/src/test/compile-fail/conflicting-repr-hints.rs b/src/test/compile-fail/conflicting-repr-hints.rs
index e4a9205409b..12ac8fb57b1 100644
--- a/src/test/compile-fail/conflicting-repr-hints.rs
+++ b/src/test/compile-fail/conflicting-repr-hints.rs
@@ -28,14 +28,31 @@ enum D { D }
 struct E(i32);
 
 #[repr(packed, align(8))]
-struct F(i32); //~ ERROR struct has conflicting packed and align representation hints
+struct F(i32); //~ ERROR type has conflicting packed and align representation hints
 
 #[repr(packed)]
 #[repr(align(8))]
-struct G(i32); //~ ERROR struct has conflicting packed and align representation hints
+struct G(i32); //~ ERROR type has conflicting packed and align representation hints
 
 #[repr(align(8))]
 #[repr(packed)]
-struct H(i32); //~ ERROR struct has conflicting packed and align representation hints
+struct H(i32); //~ ERROR type has conflicting packed and align representation hints
+
+#[repr(packed, align(8))]
+union X { //~ ERROR type has conflicting packed and align representation hints
+    i: i32
+}
+
+#[repr(packed)]
+#[repr(align(8))]
+union Y { //~ ERROR type has conflicting packed and align representation hints
+    i: i32
+}
+
+#[repr(align(8))]
+#[repr(packed)]
+union Z { //~ ERROR type has conflicting packed and align representation hints
+    i: i32
+}
 
 fn main() {}
diff --git a/src/test/compile-fail/repr-packed-contains-align.rs b/src/test/compile-fail/repr-packed-contains-align.rs
index c584dcf3e59..78d43064ea3 100644
--- a/src/test/compile-fail/repr-packed-contains-align.rs
+++ b/src/test/compile-fail/repr-packed-contains-align.rs
@@ -9,17 +9,53 @@
 // except according to those terms.
 #![feature(attr_literals)]
 #![feature(repr_align)]
+#![feature(untagged_unions)]
 #![allow(dead_code)]
 
 #[repr(align(16))]
-struct A(i32);
+struct SA(i32);
 
-struct B(A);
+struct SB(SA);
+
+#[repr(align(16))]
+union UA {
+    i: i32
+}
+
+union UB {
+    a: UA
+}
+
+#[repr(packed)]
+struct SC(SA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
+
+#[repr(packed)]
+struct SD(SB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
+
+#[repr(packed)]
+struct SE(UA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
+
+#[repr(packed)]
+struct SF(UB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
+
+#[repr(packed)]
+union UC { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
+    a: UA
+}
+
+#[repr(packed)]
+union UD { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
+    n: UB
+}
 
 #[repr(packed)]
-struct C(A); //~ ERROR: packed struct cannot transitively contain a `[repr(align)]` struct
+union UE { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
+    a: SA
+}
 
 #[repr(packed)]
-struct D(B); //~ ERROR: packed struct cannot transitively contain a `[repr(align)]` struct
+union UF { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type
+    n: SB
+}
 
 fn main() {}