summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/loop_unchecked_conversion.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gnat.dg/loop_unchecked_conversion.adb')
-rw-r--r--gcc/testsuite/gnat.dg/loop_unchecked_conversion.adb33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/loop_unchecked_conversion.adb b/gcc/testsuite/gnat.dg/loop_unchecked_conversion.adb
new file mode 100644
index 000000000..e87c415c5
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/loop_unchecked_conversion.adb
@@ -0,0 +1,33 @@
+-- { dg-do compile }
+-- { dg-options "-gnatws -O" }
+
+with Unchecked_Conversion;
+
+package body loop_unchecked_conversion is
+
+ type Byte is mod 2**8;
+
+ type List is array (Natural range <>) of Byte;
+
+ subtype Integer_List is List (1 .. 4);
+
+ function Integer_Down is new
+ Unchecked_Conversion (Source => Integer, Target => Integer_List);
+
+ type Storage (Size : Integer) is
+ record
+ Data : List (1 .. Size);
+ end record;
+
+ type Storage_Pointer is access Storage;
+
+ The_Data_Storage : Storage_Pointer;
+
+ procedure slice is
+ begin
+ for I in 0 .. 1 loop
+ The_Data_Storage.Data (I+1 .. I+4) := Integer_Down (I);
+ end loop;
+ end;
+
+end loop_unchecked_conversion;