diff options
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r-- | gcc/testsuite/gnat.dg/in_out_parameter2.adb | 24 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/in_out_parameter3.adb | 42 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/loop_optimization8.adb | 30 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/loop_optimization8_pkg1.adb | 15 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/loop_optimization8_pkg1.ads | 20 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/loop_optimization8_pkg2.adb | 13 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/loop_optimization8_pkg2.ads | 16 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt7.adb | 44 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt7.ads | 12 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt7_pkg.ads | 5 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/pointer_discr1.adb | 9 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/pointer_discr1_pkg1.ads | 9 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/pointer_discr1_pkg2.ads | 10 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/pointer_discr1_pkg3.ads | 13 |
14 files changed, 262 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/in_out_parameter2.adb b/gcc/testsuite/gnat.dg/in_out_parameter2.adb new file mode 100644 index 00000000000..1b5cc7e6abf --- /dev/null +++ b/gcc/testsuite/gnat.dg/in_out_parameter2.adb @@ -0,0 +1,24 @@ +-- { dg-do run } +-- { dg-options "-gnat12" } + +procedure In_Out_Parameter2 is + + function F (I : In Out Integer) return Boolean is + A : Integer := I; + begin + I := I + 1; + return (A > 0); + end; + + I : Integer := 0; + B : Boolean; + +begin + B := F (I); + if B then + raise Program_Error; + end if; + if I /= 1 then + raise Program_Error; + end if; +end; diff --git a/gcc/testsuite/gnat.dg/in_out_parameter3.adb b/gcc/testsuite/gnat.dg/in_out_parameter3.adb new file mode 100644 index 00000000000..dab3f8d52df --- /dev/null +++ b/gcc/testsuite/gnat.dg/in_out_parameter3.adb @@ -0,0 +1,42 @@ +-- { dg-do run } +-- { dg-options "-gnat12" } + +procedure In_Out_Parameter3 is + + type Arr is array (1..16) of Integer; + + type Rec1 is record + A : Arr; + B : Boolean; + end record; + + type Rec2 is record + R : Rec1; + end record; + pragma Pack (Rec2); + + function F (I : In Out Rec1) return Boolean is + A : Integer := I.A (1); + begin + I.A (1) := I.A (1) + 1; + return (A > 0); + end; + + I : Rec2 := (R => (A => (others => 0), B => True)); + B : Boolean; + +begin + B := F (I.R); + if B then + raise Program_Error; + end if; + if I.R.A (1) /= 1 then + raise Program_Error; + end if; + if F (I.R) = False then + raise Program_Error; + end if; + if I.R.A (1) /= 2 then + raise Program_Error; + end if; +end; diff --git a/gcc/testsuite/gnat.dg/loop_optimization8.adb b/gcc/testsuite/gnat.dg/loop_optimization8.adb new file mode 100644 index 00000000000..6be28f11347 --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization8.adb @@ -0,0 +1,30 @@ +-- { dg-do run } +-- { dg-options "-O -gnatn" } + +with Loop_Optimization8_Pkg1; + +procedure Loop_Optimization8 is + + Data : Loop_Optimization8_Pkg1.T; + + procedure Check_1 (N : in Natural) is + begin + if N /= 0 then + for I in 1 .. Data.Last loop + declare + F : constant Natural := Data.Elements (I); + begin + if F = N then + raise Program_Error; + end if; + end; + end loop; + end if; + end; + + procedure Check is new Loop_Optimization8_Pkg1.Iter (Check_1); + +begin + Data := Loop_Optimization8_Pkg1.Empty; + Check; +end; diff --git a/gcc/testsuite/gnat.dg/loop_optimization8_pkg1.adb b/gcc/testsuite/gnat.dg/loop_optimization8_pkg1.adb new file mode 100644 index 00000000000..3c3368dd479 --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization8_pkg1.adb @@ -0,0 +1,15 @@ +with Loop_Optimization8_Pkg2; + +package body Loop_Optimization8_Pkg1 is + + Data : Loop_Optimization8_Pkg2.T + := new Loop_Optimization8_Pkg2.Obj_T'(Length =>1, Elements => (1 => 1)); + + procedure Iter is + begin + for I in 1 .. Loop_Optimization8_Pkg2.Length (Data) loop + Action (Loop_Optimization8_Pkg2.Index (Data, I)); + end loop; + end; + +end Loop_Optimization8_Pkg1; diff --git a/gcc/testsuite/gnat.dg/loop_optimization8_pkg1.ads b/gcc/testsuite/gnat.dg/loop_optimization8_pkg1.ads new file mode 100644 index 00000000000..e6f3c702102 --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization8_pkg1.ads @@ -0,0 +1,20 @@ +with Ada.Finalization; + +package Loop_Optimization8_Pkg1 is + + type Array_T is array (Positive range <>) of Natural; + + type Array_Access_T is access Array_T; + + type T is new Ada.Finalization.Controlled with record + Last : Natural := 0; + Elements : Array_Access_T; + end record; + + Empty : T := (Ada.Finalization.Controlled with Last => 0, Elements => null); + + generic + with procedure Action (Info : Natural); + procedure Iter; + +end Loop_Optimization8_Pkg1; diff --git a/gcc/testsuite/gnat.dg/loop_optimization8_pkg2.adb b/gcc/testsuite/gnat.dg/loop_optimization8_pkg2.adb new file mode 100644 index 00000000000..9b9a3dea170 --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization8_pkg2.adb @@ -0,0 +1,13 @@ +package body Loop_Optimization8_Pkg2 is + + function Length (Set : T) return Natural is + begin + return Set.Length; + end Length; + + function Index (Set : T; Position : Natural) return Integer is + begin + return Set.Elements (Position); + end Index; + +end Loop_Optimization8_Pkg2; diff --git a/gcc/testsuite/gnat.dg/loop_optimization8_pkg2.ads b/gcc/testsuite/gnat.dg/loop_optimization8_pkg2.ads new file mode 100644 index 00000000000..b92cb588bd1 --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization8_pkg2.ads @@ -0,0 +1,16 @@ +package Loop_Optimization8_Pkg2 is + + type Array_T is array (Natural range <>) of Integer; + + type Obj_T (Length : Natural) is + record + Elements : Array_T (1 .. Length); + end record; + + type T is access Obj_T; + + function Length (Set : T) return Natural; + function Index (Set : T; Position : Natural) return Integer; + pragma Inline (Length, Index); + +end Loop_Optimization8_Pkg2; diff --git a/gcc/testsuite/gnat.dg/opt7.adb b/gcc/testsuite/gnat.dg/opt7.adb new file mode 100644 index 00000000000..da3b0e6dfa2 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt7.adb @@ -0,0 +1,44 @@ +-- { dg-do compile }
+-- { dg-options "-Os -g" }
+
+with Opt7_Pkg;
+
+package body Opt7 is
+
+ procedure Parse (Str : String;
+ Time_Type : out time_t;
+ Abs_Time : out Time;
+ Delt_Time : out Duration) is
+ Year : Year_Number;
+ Month : Month_Number;
+ Day : Day_Number;
+ Minute : Integer := 0;
+ Idx : Integer := Str'First;
+ Ch : Character := Str (Idx);
+ Current_Time : Time;
+
+ begin
+ if Ch = '-' then
+ Time_Type := Absolute_Time;
+ Current_Time := Clock;
+ Day := Ada.Calendar.Day (Current_Time);
+ Month := Ada.Calendar.Month (Current_Time);
+ Year := Ada.Calendar.Year (Current_Time);
+ else
+ Time_Type := Delta_Time;
+ end if;
+ while Ch in '0' .. '9' loop
+ Minute := Minute + Character'Pos (Ch);
+ Idx := Idx + 1;
+ Ch := Str (Idx);
+ end loop;
+ if Time_Type = Absolute_Time then
+ Abs_Time := Time_Of (Year, Month, Day, Day_Duration (1));
+ else
+ Delt_Time := Duration (Float (Minute));
+ end if;
+ exception
+ when others => Opt7_Pkg.My_Raise_Exception;
+ end;
+
+end Opt7;
diff --git a/gcc/testsuite/gnat.dg/opt7.ads b/gcc/testsuite/gnat.dg/opt7.ads new file mode 100644 index 00000000000..c9803532670 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt7.ads @@ -0,0 +1,12 @@ +with Ada.Calendar; use Ada.Calendar;
+
+package Opt7 is
+
+ type time_t is (Absolute_Time, Delta_Time);
+
+ procedure Parse (Str : String;
+ Time_Type : out time_t;
+ Abs_Time : out Time;
+ Delt_Time : out Duration);
+
+end Opt7;
diff --git a/gcc/testsuite/gnat.dg/opt7_pkg.ads b/gcc/testsuite/gnat.dg/opt7_pkg.ads new file mode 100644 index 00000000000..db24f5dac7b --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt7_pkg.ads @@ -0,0 +1,5 @@ +package Opt7_Pkg is + + procedure My_Raise_Exception; + +end Opt7_Pkg; diff --git a/gcc/testsuite/gnat.dg/pointer_discr1.adb b/gcc/testsuite/gnat.dg/pointer_discr1.adb new file mode 100644 index 00000000000..e3c171e16e8 --- /dev/null +++ b/gcc/testsuite/gnat.dg/pointer_discr1.adb @@ -0,0 +1,9 @@ +-- { dg-do compile } + +with Pointer_Discr1_Pkg1; +with Pointer_Discr1_Pkg3; + +procedure Pointer_Discr1 is +begin + Pointer_Discr1_Pkg3.Map(Pointer_Discr1_Pkg1.Window(1)); +end; diff --git a/gcc/testsuite/gnat.dg/pointer_discr1_pkg1.ads b/gcc/testsuite/gnat.dg/pointer_discr1_pkg1.ads new file mode 100644 index 00000000000..a930af2fdd1 --- /dev/null +++ b/gcc/testsuite/gnat.dg/pointer_discr1_pkg1.ads @@ -0,0 +1,9 @@ +with Pointer_Discr1_Pkg2; + +package Pointer_Discr1_Pkg1 is + + type Arr is array (1..4) of Pointer_Discr1_Pkg2.T_WINDOW; + + Window : Arr; + +end Pointer_Discr1_Pkg1; diff --git a/gcc/testsuite/gnat.dg/pointer_discr1_pkg2.ads b/gcc/testsuite/gnat.dg/pointer_discr1_pkg2.ads new file mode 100644 index 00000000000..c5106907387 --- /dev/null +++ b/gcc/testsuite/gnat.dg/pointer_discr1_pkg2.ads @@ -0,0 +1,10 @@ +with Unchecked_Conversion; +with Pointer_Discr1_Pkg3; + +package Pointer_Discr1_Pkg2 is + + subtype T_WINDOW is Pointer_Discr1_Pkg3.T_WINDOW(Pointer_Discr1_Pkg3.One); + + function TO_WINDOW is new Unchecked_Conversion(Integer, T_WINDOW); + +end Pointer_Discr1_Pkg2; diff --git a/gcc/testsuite/gnat.dg/pointer_discr1_pkg3.ads b/gcc/testsuite/gnat.dg/pointer_discr1_pkg3.ads new file mode 100644 index 00000000000..b27b5149ae9 --- /dev/null +++ b/gcc/testsuite/gnat.dg/pointer_discr1_pkg3.ads @@ -0,0 +1,13 @@ +package Pointer_Discr1_Pkg3 is + + type T_TYPE is (One, Two, Three); + + type T_DATA (D : T_TYPE); + + type T_DATA (D : T_TYPE) is null record; + + type T_WINDOW is access T_DATA; + + procedure Map (Window : in T_WINDOW); + +end Pointer_Discr1_Pkg3; |