Skip to content

Commit 88e0237

Browse files
swurzingerStefan Wurzinger
authored andcommitted
add unit test for #858
1 parent 07d0bb1 commit 88e0237

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/structs/padding.bas

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,5 +1468,26 @@ SUITE( fbc_tests.structs.padding )
14681468
CU_ASSERT( x2.x1.i = 11 )
14691469
CU_ASSERT( x2.b = 22 )
14701470
END_TEST
1471+
1472+
TEST( genGccUdtPackedFieldInUdt )
1473+
'' Regression test for -gen gcc's struct emitting
1474+
1475+
type UDT1 field=1 '' packed UDT
1476+
a as byte '' 1 byte
1477+
b as short '' 2 bytes
1478+
end type
1479+
#assert sizeof( UDT1 ) = sizeof( byte ) + sizeof ( short )
1480+
#assert sizeof( UDT1 ) = 3
14711481

1482+
type UDT2 field=2 '' packed UDT
1483+
x1 as UDT1 '' UDT field, which is packed with field=1
1484+
end type
1485+
#assert sizeof( UDT2 ) = 4
1486+
#assert offsetof(UDT2, x1.b) = 1
1487+
1488+
dim x2 as UDT2 = ((11,22))
1489+
CU_ASSERT( x2.x1.a = 11 )
1490+
CU_ASSERT( x2.x1.b = 22 )
1491+
END_TEST
1492+
14721493
END_SUITE

0 commit comments

Comments
 (0)