loop_address2.adb: New test.
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 14 Apr 2008 11:34:05 +0000 (11:34 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 14 Apr 2008 11:34:05 +0000 (11:34 +0000)
* gnat.dg/loop_address2.adb: New test.

From-SVN: r134258

gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/loop_address2.adb [new file with mode: 0644]

index 3229eb0ad8280b364246effff7764b450ff67fcc..23a6dd3c0a673647bb91bca60e21ac0971c82cd4 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-14  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/loop_address2.adb: New test.
+
 2008-04-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/35882
diff --git a/gcc/testsuite/gnat.dg/loop_address2.adb b/gcc/testsuite/gnat.dg/loop_address2.adb
new file mode 100644 (file)
index 0000000..aa955d7
--- /dev/null
@@ -0,0 +1,26 @@
+-- { dg-do compile }\r
+-- { dg-options "-O" }\r
+\r
+with System, Ada.Unchecked_Conversion;\r
+with System.Storage_Elements; use System.Storage_Elements;\r
+\r
+procedure Loop_Address2 is\r
+\r
+  type Ptr is access all Integer;\r
+\r
+  function To_Ptr is new Ada.Unchecked_Conversion (System.Address, Ptr);\r
+\r
+  function F (BM : System.Address; I : Integer) return System.Address is\r
+  begin\r
+    return BM + Storage_Offset (4*I);\r
+  end;\r
+\r
+  B : Integer;\r
+  P : Ptr;\r
+\r
+begin\r
+  for I in 0 .. 2 loop\r
+    P := To_Ptr (F (B'Address, I));\r
+    P.all := 0;\r
+  end loop;\r
+end ;\r