summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r--gcc/testsuite/gnat.dg/frame_overflow.adb8
-rw-r--r--gcc/testsuite/gnat.dg/pack3.adb31
-rw-r--r--gcc/testsuite/gnat.dg/pack4.adb38
-rw-r--r--gcc/testsuite/gnat.dg/range_check2.adb13
-rw-r--r--gcc/testsuite/gnat.dg/small_alignment.adb28
-rw-r--r--gcc/testsuite/gnat.dg/specs/alignment2.ads47
-rw-r--r--gcc/testsuite/gnat.dg/specs/pack33.ads27
-rw-r--r--gcc/testsuite/gnat.dg/uninit_func.adb13
8 files changed, 202 insertions, 3 deletions
diff --git a/gcc/testsuite/gnat.dg/frame_overflow.adb b/gcc/testsuite/gnat.dg/frame_overflow.adb
index 4172fc013ce..286c93d5983 100644
--- a/gcc/testsuite/gnat.dg/frame_overflow.adb
+++ b/gcc/testsuite/gnat.dg/frame_overflow.adb
@@ -1,15 +1,17 @@
-- { dg-do compile }
+with System;
+
procedure frame_overflow is
- type Bitpos_Range_T is new Positive;
+ type Bitpos_Range_T is range 1..2**(System.Word_Size-1)-1;
type Bitmap_Array_T is array (Bitpos_Range_T) of Boolean;
type Bitmap_T is record
Bits : Bitmap_Array_T := (others => False);
end record;
- function -- { dg-error "too large" "" }
+ function -- { dg-error "too large" }
Set_In (Bitmap : Bitmap_T; Bitpos : Bitpos_Range_T) return Bitmap_T
is
Result: Bitmap_T := Bitmap;
@@ -18,7 +20,7 @@ procedure frame_overflow is
return Result;
end;
- function -- { dg-error "too large" "" }
+ function -- { dg-error "too large" }
Negate (Bitmap : Bitmap_T) return Bitmap_T is
Result: Bitmap_T;
begin
diff --git a/gcc/testsuite/gnat.dg/pack3.adb b/gcc/testsuite/gnat.dg/pack3.adb
new file mode 100644
index 00000000000..06f71cbe91d
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/pack3.adb
@@ -0,0 +1,31 @@
+-- { dg-do run }
+
+procedure Pack3 is
+
+ type U32 is mod 2 ** 32;
+
+ type Key is record
+ Value : U32;
+ Valid : Boolean;
+ end record;
+
+ type Key_Buffer is record
+ Current, Latch : Key;
+ end record;
+
+ type Block is record
+ Keys : Key_Buffer;
+ Stamp : U32;
+ end record;
+ pragma Pack (Block);
+
+ My_Block : Block;
+ My_Stamp : constant := 16#01234567#;
+
+begin
+ My_Block.Stamp := My_Stamp;
+ My_Block.Keys.Latch := My_Block.Keys.Current;
+ if My_Block.Stamp /= My_Stamp then
+ raise Program_Error;
+ end if;
+end;
diff --git a/gcc/testsuite/gnat.dg/pack4.adb b/gcc/testsuite/gnat.dg/pack4.adb
new file mode 100644
index 00000000000..2c73e1dd4ea
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/pack4.adb
@@ -0,0 +1,38 @@
+-- { dg-do run }
+
+procedure Pack4 is
+
+ type Time_T is record
+ Hour : Integer;
+ end record;
+
+ type Date_And_Time_T is record
+ Date : Integer;
+ Time : Time_T;
+ end record;
+
+ pragma Pack(Date_And_Time_T);
+
+ procedure
+ Assign_Hour_Of (T : out Time_T)
+ is
+ begin
+ T.Hour := 44;
+ end;
+
+ procedure
+ Clobber_Hour_Of (DT: out Date_And_Time_T)
+ is
+ begin
+ Assign_Hour_Of (Dt.Time);
+ end;
+
+ DT : Date_And_Time_T;
+
+begin
+ DT.Time.Hour := 22;
+ Clobber_Hour_Of (DT);
+ if DT.Time.Hour /= 44 then
+ raise Program_Error;
+ end if;
+end;
diff --git a/gcc/testsuite/gnat.dg/range_check2.adb b/gcc/testsuite/gnat.dg/range_check2.adb
new file mode 100644
index 00000000000..33172f155e5
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/range_check2.adb
@@ -0,0 +1,13 @@
+-- { dg-do compile }
+-- { dg-options "-O2" }
+
+procedure Range_Check2 is
+
+ subtype Block_Subtype is String(1 .. 6);
+ type Color is (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White);
+ Foregrnd_Color : Color := White;
+ Block : Block_Subtype := "123456";
+
+begin
+ Foregrnd_Color := Color'Val(Integer'Value(Block(5 .. 6)));
+end;
diff --git a/gcc/testsuite/gnat.dg/small_alignment.adb b/gcc/testsuite/gnat.dg/small_alignment.adb
new file mode 100644
index 00000000000..fbe1c21457c
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/small_alignment.adb
@@ -0,0 +1,28 @@
+-- { dg-do run }
+-- { dg-options "-gnatws" }
+
+procedure Small_Alignment is
+
+ type My_Integer is new Integer;
+ for My_Integer'Alignment use 1;
+
+ function Set_A return My_Integer is
+ begin
+ return 12;
+ end;
+
+ function Set_B return My_Integer is
+ begin
+ return 6;
+ end;
+
+ C : Character;
+ A : My_Integer := Set_A;
+ B : My_Integer := Set_B;
+
+begin
+ A := A * B / 2;
+ if A /= 36 then
+ raise Program_Error;
+ end if;
+end;
diff --git a/gcc/testsuite/gnat.dg/specs/alignment2.ads b/gcc/testsuite/gnat.dg/specs/alignment2.ads
new file mode 100644
index 00000000000..8dce1a8c366
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/alignment2.ads
@@ -0,0 +1,47 @@
+-- { dg-do compile }
+
+with Interfaces; use Interfaces;
+
+package Alignment2 is
+
+ -- warning
+ type R1 is record
+ A, B, C, D : Integer_8;
+ end record;
+ for R1'Size use 32;
+ for R1'Alignment use 32; -- { dg-warning "suspiciously large alignment" }
+
+ -- warning
+ type R2 is record
+ A, B, C, D : Integer_8;
+ end record;
+ for R2'Alignment use 32; -- { dg-warning "suspiciously large alignment" }
+
+ -- OK, big size
+ type R3 is record
+ A, B, C, D : Integer_8;
+ end record;
+ for R3'Size use 32 * 8;
+ for R3'Alignment use 32;
+
+ -- OK, big size
+ type R4 is record
+ A, B, C, D, E, F, G, H : Integer_32;
+ end record;
+ for R4'Alignment use 32;
+
+ -- warning
+ type I1 is new Integer_32;
+ for I1'Size use 32;
+ for I1'Alignment use 32; -- { dg-warning "suspiciously large alignment" }
+
+ -- warning
+ type I2 is new Integer_32;
+ for I2'Alignment use 32; -- { dg-warning "suspiciously large alignment" }
+
+ -- OK, big size
+ type I3 is new Integer_32;
+ for I3'Size use 32 * 8;
+ for I3'Alignment use 32;
+
+end Alignment2;
diff --git a/gcc/testsuite/gnat.dg/specs/pack33.ads b/gcc/testsuite/gnat.dg/specs/pack33.ads
new file mode 100644
index 00000000000..d5255aa4431
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/pack33.ads
@@ -0,0 +1,27 @@
+-- { dg-do compile }
+
+package Pack33 is
+
+ Bits : constant := 33;
+
+ type Bits_33 is mod 2 ** Bits;
+ for Bits_33'Size use Bits;
+
+ type Cluster is record
+ E0, E1, E2, E3, E4, E5, E6, E7 : Bits_33;
+ end record;
+
+ for Cluster use record
+ E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
+ E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
+ E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
+ E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
+ E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
+ E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
+ E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
+ E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
+ end record;
+
+ for Cluster'Size use Bits * 8;
+
+end Pack33;
diff --git a/gcc/testsuite/gnat.dg/uninit_func.adb b/gcc/testsuite/gnat.dg/uninit_func.adb
new file mode 100644
index 00000000000..9c9ee341143
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/uninit_func.adb
@@ -0,0 +1,13 @@
+-- { dg-do compile }
+-- { dg-options "-O -Wall" }
+
+function uninit_func (A, B : Boolean) return Boolean is
+ C : Boolean; -- { dg-warning "may be used uninitialized" }
+begin
+ if A then
+ C := False;
+ elsif B then
+ C := True;
+ end if;
+ return C;
+end;