gcc/testsuite/gnat.dg/aliased2.adb
raw| 1 | -- { dg-do run } |
| 2 | |
| 3 | procedure Aliased2 is |
| 4 | |
| 5 | type Rec is record |
| 6 | Data : access constant String; |
| 7 | end record; |
| 8 | |
| 9 | function Get (S : aliased String) return Rec is |
| 10 | R : Rec := (Data => S'Unchecked_Access); |
| 11 | begin |
| 12 | return R; |
| 13 | end; |
| 14 | |
| 15 | S : aliased String := "Hello"; |
| 16 | |
| 17 | R : Rec := Get (S); |
| 18 | |
| 19 | begin |
| 20 | if R.Data'Length /= S'Length then |
| 21 | raise Program_Error; |
| 22 | end if; |
| 23 | end; |