summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/blkextract_from_reg.adb
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gnat.dg/blkextract_from_reg.adb
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gnat.dg/blkextract_from_reg.adb')
-rw-r--r--gcc/testsuite/gnat.dg/blkextract_from_reg.adb49
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/blkextract_from_reg.adb b/gcc/testsuite/gnat.dg/blkextract_from_reg.adb
new file mode 100644
index 000000000..204d71964
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/blkextract_from_reg.adb
@@ -0,0 +1,49 @@
+-- { dg-do run }
+
+with System, Ada.Unchecked_Conversion; use System;
+
+procedure BLKextract_From_Reg is
+
+ type Byte is range 0 .. +255;
+ for Byte'size use 8;
+
+ type RGB is array (1 .. 3) of Byte;
+ for RGB'Size use 24;
+
+ type RAW_Packet is range 0 .. 2 ** 32 - 1;
+ for RAW_Packet'Size use 32;
+
+ type Composite_Packet is record
+ Values : RGB;
+ Pad : Byte;
+ end record;
+ for Composite_Packet use record
+ Values at 0 range 0 .. 23;
+ Pad at 3 range 0 .. 7;
+ end record;
+ for Composite_Packet'Size use 32;
+
+ function To_Composite_Packet is
+ new Ada.Unchecked_Conversion (RAW_Packet, Composite_Packet);
+
+ function Blob return RGB is
+ RAW_Blob : RAW_Packet := 16#01020304#;
+ begin
+ return To_Composite_Packet (RAW_Blob).Values;
+ end;
+
+ Blob_Color : RGB := Blob;
+ Expected_Color : RGB;
+begin
+ if System.Default_Bit_Order = High_Order_First then
+ Expected_Color := (1 => 1, 2 => 2, 3 => 3);
+ else
+ Expected_Color := (1 => 4, 2 => 3, 3 => 2);
+ end if;
+
+ for I in Blob_Color'Range loop
+ if Blob_Color (I) /= Expected_Color (I) then
+ raise Program_Error;
+ end if;
+ end loop;
+end;