diff options
Diffstat (limited to 'gcc/testsuite/gnat.dg/slice1.adb')
-rw-r--r-- | gcc/testsuite/gnat.dg/slice1.adb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/slice1.adb b/gcc/testsuite/gnat.dg/slice1.adb new file mode 100644 index 000000000..4c24975f7 --- /dev/null +++ b/gcc/testsuite/gnat.dg/slice1.adb @@ -0,0 +1,19 @@ +-- { dg-do compile } +-- { dg-options "-O2" } + +function slice1 (Offset : Integer) return String is + + Convert : constant String := "0123456789abcdef"; + Buffer : String (1 .. 32); + Pos : Natural := Buffer'Last; + Value : Long_Long_Integer := Long_Long_Integer (Offset); + +begin + while Value > 0 loop + Buffer (Pos) := Convert (Integer (Value mod 16)); + Pos := Pos - 1; + Value := Value / 16; + end loop; + + return Buffer (Pos + 1 .. Buffer'Last); +end; |