gcc/testsuite/gnat.dg/range_check6.adb
raw| 1 | -- { dg-do run } |
| 2 | -- { dg-options "-O0 -gnatVa" } |
| 3 | |
| 4 | procedure Range_Check6 is |
| 5 | |
| 6 | type Byte is range -2**7 .. 2**7-1; |
| 7 | for Byte'Size use 8; |
| 8 | |
| 9 | subtype Hour is Byte range 0 .. 23; |
| 10 | |
| 11 | type Rec is record |
| 12 | B : Byte; |
| 13 | end record; |
| 14 | |
| 15 | procedure Encode (H : in out Hour) is |
| 16 | begin |
| 17 | null; |
| 18 | end; |
| 19 | |
| 20 | R : Rec; |
| 21 | |
| 22 | begin |
| 23 | R.B := 24; |
| 24 | Encode (R.B); |
| 25 | raise Program_Error; |
| 26 | exception |
| 27 | when Constraint_Error => null; |
| 28 | end; |