gcc/testsuite/gnat.dg/unchecked_union1.adb
raw| 1 | -- { dg-do run } |
| 2 | |
| 3 | procedure Unchecked_Union1 is |
| 4 | |
| 5 | type Bit is (Zero, One); |
| 6 | |
| 7 | type U (X : Bit := Zero) is record |
| 8 | case X is |
| 9 | when Zero => I: Integer; |
| 10 | when One => F : Float; |
| 11 | end case; |
| 12 | end record; |
| 13 | for U use record |
| 14 | I at 0 range 0 .. 31; |
| 15 | F at 0 range 0 .. 31; |
| 16 | end record; |
| 17 | pragma Unchecked_Union(U); |
| 18 | |
| 19 | begin |
| 20 | if U'Object_Size /= 32 then |
| 21 | raise Program_Error; |
| 22 | end if; |
| 23 | end; |