aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/opt1.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gnat.dg/opt1.adb')
-rw-r--r--gcc/testsuite/gnat.dg/opt1.adb29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/opt1.adb b/gcc/testsuite/gnat.dg/opt1.adb
new file mode 100644
index 00000000000..69bb8136d04
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt1.adb
@@ -0,0 +1,29 @@
+-- { dg-do compile }
+-- { dg-options "-O -gnatws" }
+
+package body Opt1 is
+
+ function De_Linear_Index
+ (Index : Natural;
+ D : Natural;
+ Ind_Lengths : Dimention_Length)
+ return Dimension_Indexes
+ is
+ Len : Natural := 1;
+ Tmp_Ind : Natural := Index;
+ Tmp_Res : Natural;
+ Result : Dimension_Indexes (1 .. D);
+ begin
+ for J in 1 .. D loop
+ Len := Len * Ind_Lengths (J);
+ end loop;
+
+ for J in Result'Range loop
+ Result (J) := Tmp_Res;
+ Tmp_Ind := Tmp_Ind - Len * (Result (J) - 1);
+ end loop;
+
+ return Result;
+ end;
+
+end Opt1;