| 1 |
-- { dg-do compile } |
| 2 |
-- { dg-options "-O3" } |
| 3 |
|
| 4 |
procedure Opt45 is |
| 5 |
|
| 6 |
type Index_T is mod 2 ** 32; |
| 7 |
for Index_T'Size use 32; |
| 8 |
for Index_T'Alignment use 1; |
| 9 |
|
| 10 |
type Array_T is array (Index_T range <>) of Natural; |
| 11 |
type Array_Ptr_T is access all Array_T; |
| 12 |
|
| 13 |
My_Array_1 : aliased Array_T := (1, 2); |
| 14 |
My_Array_2 : aliased Array_T := (3, 4); |
| 15 |
|
| 16 |
Array_Ptr : Array_Ptr_T := null; |
| 17 |
Index : Index_T := Index_T'First; |
| 18 |
|
| 19 |
My_Value : Natural := Natural'First; |
| 20 |
|
| 21 |
procedure Proc (Selection : Positive) is |
| 22 |
begin |
| 23 |
if Selection = 1 then |
| 24 |
Array_Ptr := My_Array_1'Access; |
| 25 |
Index := My_Array_1'First; |
| 26 |
else |
| 27 |
Array_Ptr := My_Array_2'Access; |
| 28 |
Index := My_Array_2'First; |
| 29 |
end if; |
| 30 |
|
| 31 |
if My_Value = Natural'First then |
| 32 |
My_Value := Array_Ptr.all (Index); |
| 33 |
end if; |
| 34 |
end; |
| 35 |
|
| 36 |
begin |
| 37 |
Proc (2); |
| 38 |
end; |