Preserving locations for variable-uses and constants (PR c++/43486)
[official-gcc.git] / gcc / testsuite / gnat.dg / opt1.adb
blob69bb8136d04b5fa8826a492800ec4f27851acde2
1 -- { dg-do compile }
2 -- { dg-options "-O -gnatws" }
4 package body Opt1 is
6 function De_Linear_Index
7 (Index : Natural;
8 D : Natural;
9 Ind_Lengths : Dimention_Length)
10 return Dimension_Indexes
12 Len : Natural := 1;
13 Tmp_Ind : Natural := Index;
14 Tmp_Res : Natural;
15 Result : Dimension_Indexes (1 .. D);
16 begin
17 for J in 1 .. D loop
18 Len := Len * Ind_Lengths (J);
19 end loop;
21 for J in Result'Range loop
22 Result (J) := Tmp_Res;
23 Tmp_Ind := Tmp_Ind - Len * (Result (J) - 1);
24 end loop;
26 return Result;
27 end;
29 end Opt1;