]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add new tests
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 7 Jun 2007 13:44:58 +0000 (15:44 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 7 Jun 2007 13:44:58 +0000 (15:44 +0200)
From-SVN: r125529

gcc/testsuite/gnat.dg/aliased_prefix_accessibility.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/asynch.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/asynch.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/bip_prim_func.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/bip_prim_func.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/fixedpnt.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/interface3.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/access3.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/tagged_type_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/tagged_type_pkg.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/valid1.adb [new file with mode: 0644]

diff --git a/gcc/testsuite/gnat.dg/aliased_prefix_accessibility.adb b/gcc/testsuite/gnat.dg/aliased_prefix_accessibility.adb
new file mode 100644 (file)
index 0000000..c41a4bc
--- /dev/null
@@ -0,0 +1,68 @@
+--  { dg-do run }
+
+with Tagged_Type_Pkg;  use Tagged_Type_Pkg;
+with Ada.Text_IO;      use Ada.Text_IO;
+      
+procedure Aliased_Prefix_Accessibility is
+   
+  T_Obj : aliased TT;
+         
+   T_Obj_Acc : access TT'Class := T_Obj'Access;
+   
+   type Nested_TT is limited record
+      TT_Comp : aliased TT;
+   end record;
+
+   NTT_Obj : Nested_TT;
+
+   ATT_Obj : array (1 .. 2) of aliased TT;
+
+begin
+   begin
+      T_Obj_Acc := Pass_TT_Access (T_Obj'Access);
+      Put_Line ("FAILED (1): call should have raised an exception");
+   exception
+      when others =>
+         null;
+   end;
+
+   begin
+      T_Obj_Acc := T_Obj.Pass_TT_Access;
+      Put_Line ("FAILED (2): call should have raised an exception");
+   exception
+      when others =>
+         null;
+   end;
+
+   begin
+      T_Obj_Acc := Pass_TT_Access (NTT_Obj.TT_Comp'Access);
+      Put_Line ("FAILED (3): call should have raised an exception");
+   exception
+      when others =>
+         null;
+   end;
+   
+   begin
+      T_Obj_Acc := NTT_Obj.TT_Comp.Pass_TT_Access;
+      Put_Line ("FAILED (4): call should have raised an exception");
+   exception
+      when others =>
+         null;
+   end;
+   
+   begin
+      T_Obj_Acc := Pass_TT_Access (ATT_Obj (1)'Access);
+      Put_Line ("FAILED (5): call should have raised an exception");
+   exception
+      when others =>
+         null;
+   end;
+   
+   begin
+      T_Obj_Acc := ATT_Obj (2).Pass_TT_Access;
+      Put_Line ("FAILED (6): call should have raised an exception");
+   exception
+      when others =>
+         null;
+   end;
+end Aliased_Prefix_Accessibility;
diff --git a/gcc/testsuite/gnat.dg/asynch.adb b/gcc/testsuite/gnat.dg/asynch.adb
new file mode 100644 (file)
index 0000000..024af72
--- /dev/null
@@ -0,0 +1,24 @@
+--  { dg-do compile }
+
+package body asynch is
+   function null_ctrl return t_ctrl is
+   begin
+      return (Ada.Finalization.Controlled with stuff => 0);
+   end null_ctrl;
+   
+   procedure Proc (msg : String; c : t_ctrl := null_ctrl) is
+   begin
+      null;
+   end Proc;
+   
+   task type tsk;
+   task body tsk is
+   begin
+      select                                                    
+         delay 10.0;                                            
+         Proc ("A message.");
+      then abort
+         null;
+      end select;
+   end tsk;
+end asynch;
diff --git a/gcc/testsuite/gnat.dg/asynch.ads b/gcc/testsuite/gnat.dg/asynch.ads
new file mode 100644 (file)
index 0000000..c9b70aa
--- /dev/null
@@ -0,0 +1,8 @@
+with Ada.Finalization;
+package asynch is
+   type t_ctrl is new Ada.Finalization.Controlled with record
+      stuff : Natural := 0;
+   end record;
+   
+   function null_ctrl return t_ctrl;
+end asynch;
diff --git a/gcc/testsuite/gnat.dg/bip_prim_func.adb b/gcc/testsuite/gnat.dg/bip_prim_func.adb
new file mode 100644 (file)
index 0000000..6529fe5
--- /dev/null
@@ -0,0 +1,14 @@
+--  { dg-do compile }
+
+package body BIP_Prim_Func is
+        
+   type NTT is new TT with record
+      J : Integer;
+   end record;
+        
+   function Prim_Func return NTT is
+   begin
+      return Result : NTT := (I => 1, J => 2);
+   end Prim_Func;
+        
+end BIP_Prim_Func;
diff --git a/gcc/testsuite/gnat.dg/bip_prim_func.ads b/gcc/testsuite/gnat.dg/bip_prim_func.ads
new file mode 100644 (file)
index 0000000..37f7ac0
--- /dev/null
@@ -0,0 +1,11 @@
+
+package BIP_Prim_Func is
+   pragma Elaborate_Body;
+        
+   type TT is abstract tagged limited record
+      I : Integer;
+   end record;
+        
+   function Prim_Func return TT is abstract;
+        
+end BIP_Prim_Func;
diff --git a/gcc/testsuite/gnat.dg/fixedpnt.adb b/gcc/testsuite/gnat.dg/fixedpnt.adb
new file mode 100644 (file)
index 0000000..2e9988c
--- /dev/null
@@ -0,0 +1,10 @@
+--  { dg-do run }
+
+procedure Fixedpnt is
+   A : Duration := 1.0;
+   B : Duration := Duration ((-1.0) * A);
+begin   
+   if B > 0.0 then 
+      raise Constraint_Error;
+   end if;
+end;    
diff --git a/gcc/testsuite/gnat.dg/interface3.adb b/gcc/testsuite/gnat.dg/interface3.adb
new file mode 100644 (file)
index 0000000..da38a1f
--- /dev/null
@@ -0,0 +1,31 @@
+--  { dg-do run }
+
+procedure interface3 is
+-- 
+   package Pkg is
+      type Foo is interface;
+      subtype Element_Type is Foo'Class;
+--    
+      type Element_Access  is access Element_Type;
+      type Elements_Type   is array (1 .. 1) of Element_Access;
+      type Elements_Access is access Elements_Type;
+--    
+      type Vector is tagged record
+         Elements : Elements_Access;
+      end record;
+--    
+      procedure Test (Obj : Vector);
+   end;
+-- 
+   package body Pkg is
+      procedure Test (Obj : Vector) is
+         Elements : Elements_Access := new Elements_Type;
+--    
+      begin
+         Elements (1) := new Element_Type'(Obj.Elements (1).all);
+      end;
+   end;
+--
+begin
+   null;
+end;
diff --git a/gcc/testsuite/gnat.dg/specs/access3.ads b/gcc/testsuite/gnat.dg/specs/access3.ads
new file mode 100644 (file)
index 0000000..f7fbf7e
--- /dev/null
@@ -0,0 +1,25 @@
+--  { dg-do compile }
+
+package access3 is
+   type TF is access function return access procedure (P1 : Integer);
+   
+   type TAF is access protected function return access procedure (P1 : Integer);
+   
+   type TAF2 is access
+     function return access protected procedure (P1 : Integer);
+   
+   type TAF3 is access
+     protected function return access protected procedure (P1 : Integer);
+   
+   type TAF_Inf is
+      access protected function return
+         access function return
+         access function return
+         access function return
+         access function return
+         access function return
+         access function return
+         access function return
+         access function return
+      Integer;
+end access3;
diff --git a/gcc/testsuite/gnat.dg/tagged_type_pkg.adb b/gcc/testsuite/gnat.dg/tagged_type_pkg.adb
new file mode 100644 (file)
index 0000000..dea1b54
--- /dev/null
@@ -0,0 +1,18 @@
+package body Tagged_Type_Pkg is
+      
+   function Pass_TT_Access (Obj : access TT'Class) return access TT'Class is
+   begin
+      if Obj = null then
+         return null;
+      
+      else
+         --  The implicit conversion in the assignment to the return object
+         --  must fail if Obj's actual is not a library-level object.
+         
+         return TT_Acc : access TT'Class := Obj do
+            TT_Acc := TT_Acc.Self;
+         end return;
+      end if;
+   end Pass_TT_Access;
+   
+end Tagged_Type_Pkg;
diff --git a/gcc/testsuite/gnat.dg/tagged_type_pkg.ads b/gcc/testsuite/gnat.dg/tagged_type_pkg.ads
new file mode 100644 (file)
index 0000000..8092610
--- /dev/null
@@ -0,0 +1,9 @@
+package Tagged_Type_Pkg is
+      
+   type TT is tagged limited record
+      Self : access TT'Class := TT'Unchecked_Access;
+   end record;
+         
+   function Pass_TT_Access (Obj : access TT'Class) return access TT'Class;
+   
+end Tagged_Type_Pkg;
diff --git a/gcc/testsuite/gnat.dg/valid1.adb b/gcc/testsuite/gnat.dg/valid1.adb
new file mode 100644 (file)
index 0000000..a243767
--- /dev/null
@@ -0,0 +1,24 @@
+--  { dg-do run }
+--  { dg-options "-gnatVi" }
+
+procedure valid1 is
+   type m is range 0 .. 10;
+   for m'size use 8;
+   
+   type r is record
+      a, b : m;
+      c, d, e, f : boolean;
+   end record;
+   pragma Pack (r);
+   for R'size use 20;
+   
+   type G is array (1 .. 3, 1 .. 3) of R;
+   pragma Pack (G);
+   
+   procedure h (c : m) is begin null; end;
+   
+   GG : G := (others => (others => (2, 3, true, true, true, true)));
+
+begin
+   h (GG (3, 2).a);
+end;