summary refs log tree commit diff stats
path: root/tests/misc
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2019-03-04 09:19:38 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-03-04 09:19:38 +0100
commit1d9b88f25d8c278123133773f83fd9ce81685bac (patch)
tree041a7d66ab4a1eee901d0e44f58fd99bce9a79d5 /tests/misc
parentebe0473511f23e64a8f68cd96a7534444e21c3ca (diff)
downloadNim-1d9b88f25d8c278123133773f83fd9ce81685bac.tar.gz
sizealign of union type (#10780)
* sizealign of union type

* add error message for packed union
Diffstat (limited to 'tests/misc')
-rw-r--r--tests/misc/tsizeof.nim12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/misc/tsizeof.nim b/tests/misc/tsizeof.nim
index f2bed4743..c56e08062 100644
--- a/tests/misc/tsizeof.nim
+++ b/tests/misc/tsizeof.nim
@@ -401,7 +401,7 @@ assert sizeof(Bar) == 12
 type
   A = int8        # change to int16 and get sizeof(C)==6
   B = int16
-  C = object {.packed.}
+  C {.packed.} = object
     d {.bitsize:  1.}: A
     e {.bitsize:  7.}: A
     f {.bitsize: 16.}: B
@@ -410,7 +410,7 @@ assert sizeof(C) == 3
 
 
 type
-  MixedBitsize = object {.packed.}
+  MixedBitsize {.packed.} = object
     a: uint32
     b {.bitsize:  8.}: uint8
     c {.bitsize:  1.}: uint8
@@ -420,6 +420,14 @@ type
 
 doAssert sizeof(MixedBitsize) == 12
 
+
+type
+  MyUnionType {.union.} = object
+    a: int32
+    b: float32
+
+doAssert sizeof(MyUnionType) == 4
+
 ##########################################
 # bug #9794
 ##########################################