===================================================================
@@ -1,15 +1,17 @@
-- { dg-do compile }
+with System;
+
procedure Array11 is
type Rec is null record;
- type Ptr is access all Rec;
+ type Index_T is mod System.Memory_Size;
- type Arr1 is array (1..8) of aliased Rec; -- { dg-warning "padded" }
- type Arr2 is array (Long_Integer) of aliased Rec; -- { dg-warning "padded" }
+ type Arr1 is array (1 .. 8) of aliased Rec; -- { dg-warning "padded" }
+ type Arr2 is array (Index_T) of aliased Rec; -- { dg-warning "padded" }
A1 : Arr1;
- A2 : Arr2; -- { dg-warning "Storage_Error" }
+ A2 : Arr2;
begin
null;
===================================================================
@@ -1,7 +1,8 @@
-- { dg-do run }
-with dispatch1_p; use dispatch1_p;
-procedure dispatch1 is
+with Disp1_Pkg; use Disp1_Pkg;
+
+procedure Disp1 is
O : DT_I1;
Ptr : access I1'Class;
begin
===================================================================
@@ -1,4 +1,6 @@
-package dispatch1_p is
+package Disp1_Pkg is
+
type I1 is interface;
type DT_I1 is new I1 with null record;
-end;
+
+end Disp1_Pkg;
===================================================================
@@ -1,7 +1,8 @@
-- { dg-do run }
-with dispatch2_p; use dispatch2_p;
-procedure dispatch2 is
+with Disp2_Pkg; use Disp2_Pkg;
+
+procedure Disp2 is
Obj : Object_Ptr := new Object;
begin
if Obj.Get_Ptr /= Obj.Impl_Of then
===================================================================
@@ -1,7 +1,8 @@
---
-package body dispatch2_p is
+package body Disp2_Pkg is
+
function Impl_Of (Self : access Object) return Object_Ptr is
begin
return Object_Ptr (Self);
end Impl_Of;
-end;
+
+end Disp2_Pkg;
===================================================================
@@ -1,8 +1,11 @@
-package dispatch2_p is
+package Disp2_Pkg is
+
type Object is tagged null record;
type Object_Ptr is access all Object'CLASS;
---
+
function Impl_Of (Self : access Object) return Object_Ptr;
function Get_Ptr (Self : access Object) return Object_Ptr
renames Impl_Of;
-end;
+
+end Disp2_Pkg;
+
===================================================================
@@ -1,9 +0,0 @@
-
-with dispatch1_p; use dispatch1_p;
-procedure dispatch1 is
- O : DT_I1;
- Ptr : access I1'Class;
-begin
- Ptr := new I1'Class'(I1'Class (O));
-end;
===================================================================
@@ -1,4 +0,0 @@
-package dispatch1_p is
- type I1 is interface;
- type DT_I1 is new I1 with null record;
-end;
===================================================================
@@ -1,10 +0,0 @@
-
-with dispatch2_p; use dispatch2_p;
-procedure dispatch2 is
- Obj : Object_Ptr := new Object;
-begin
- if Obj.Get_Ptr /= Obj.Impl_Of then
- raise Program_Error;
- end if;
-end;
===================================================================
@@ -1,7 +0,0 @@
---
-package body dispatch2_p is
- function Impl_Of (Self : access Object) return Object_Ptr is
- begin
- return Object_Ptr (Self);
- end Impl_Of;
-end;
===================================================================
@@ -1,8 +0,0 @@
-package dispatch2_p is
- type Object is tagged null record;
- type Object_Ptr is access all Object'CLASS;
---
- function Impl_Of (Self : access Object) return Object_Ptr;
- function Get_Ptr (Self : access Object) return Object_Ptr
- renames Impl_Of;
-end;
===================================================================
@@ -1,9 +1,10 @@
-- { dg-do run }
-with generic_dispatch_p; use generic_dispatch_p;
-procedure generic_dispatch is
+with Generic_Disp_Pkg; use Generic_Disp_Pkg;
+
+procedure Generic_Disp is
I : aliased Integer := 0;
D : Iface'Class := Dispatching_Constructor (DT'Tag, I'access);
begin
null;
-end generic_dispatch;
+end Generic_Disp;
===================================================================
@@ -1,7 +1,9 @@
-package body generic_dispatch_p is
+package body Generic_Disp_Pkg is
+
function Constructor (I : not null access Integer) return DT is
R : DT;
- begin
+ begin
return R;
end Constructor;
-end;
+
+end Generic_Disp_Pkg;
===================================================================
@@ -1,5 +1,6 @@
with Ada.Tags.Generic_Dispatching_Constructor;
-package generic_dispatch_p is
+
+package Generic_Disp_Pkg is
type Iface is interface;
function Constructor (I : not null access Integer) return Iface is abstract;
function Dispatching_Constructor
@@ -10,4 +11,4 @@ package generic_dispatch_p is
type DT is new Iface with null record;
overriding
function Constructor (I : not null access Integer) return DT;
-end;
+end Generic_Disp_Pkg;
===================================================================
@@ -1,9 +0,0 @@
-
-with generic_dispatch_p; use generic_dispatch_p;
-procedure generic_dispatch is
- I : aliased Integer := 0;
- D : Iface'Class := Dispatching_Constructor (DT'Tag, I'access);
-begin
- null;
-end generic_dispatch;
===================================================================
@@ -1,7 +0,0 @@
-package body generic_dispatch_p is
- function Constructor (I : not null access Integer) return DT is
- R : DT;
- begin
- return R;
- end Constructor;
-end;
===================================================================
@@ -1,13 +0,0 @@
-with Ada.Tags.Generic_Dispatching_Constructor;
-package generic_dispatch_p is
- type Iface is interface;
- function Constructor (I : not null access Integer) return Iface is abstract;
- function Dispatching_Constructor
- is new Ada.Tags.Generic_Dispatching_Constructor
- (T => Iface,
- Parameters => Integer,
- Constructor => Constructor);
- type DT is new Iface with null record;
- overriding
- function Constructor (I : not null access Integer) return DT;
-end;
===================================================================
@@ -17,5 +17,5 @@ procedure Null_Pointer_Deref1 is
begin
Data.all := 1;
exception
- when Constraint_Error | Storage_Error => null;
+ when others => null;
end;
===================================================================
@@ -20,7 +20,7 @@ procedure Null_Pointer_Deref2 is
begin
Data.all := 1;
exception
- when Constraint_Error | Storage_Error => null;
+ when others => null;
end T;
begin
===================================================================
@@ -1,10 +1,12 @@
-- { dg-do compile }
+with Interfaces.C; use Interfaces.C;
+
procedure Object_Overflow1 is
procedure Proc (x : Boolean) is begin null; end;
- type Arr is array(Long_Integer) of Boolean;
+ type Arr is array(ptrdiff_t) of Boolean;
Obj : Arr; -- { dg-warning "Storage_Error" }
begin
===================================================================
@@ -1,10 +1,12 @@
-- { dg-do compile }
+with Interfaces.C; use Interfaces.C;
+
procedure Object_Overflow2 is
procedure Proc (x : Boolean) is begin null; end;
- type Arr is array(0 .. Long_Integer'Last) of Boolean;
+ type Arr is array(0 .. ptrdiff_t'Last) of Boolean;
Obj : Arr; -- { dg-warning "Storage_Error" }
begin
===================================================================
@@ -1,10 +1,12 @@
-- { dg-do compile }
+with Interfaces.C; use Interfaces.C;
+
procedure Object_Overflow3 is
procedure Proc (x : Boolean) is begin null; end;
- type Arr is array(0 .. Long_Integer'Last) of Boolean;
+ type Arr is array(0 .. ptrdiff_t'Last) of Boolean;
type Rec is record
A : Arr;
===================================================================
@@ -1,14 +1,16 @@
-- { dg-do compile }
+with Interfaces.C; use Interfaces.C;
+
procedure Object_Overflow4 is
procedure Proc (x : Integer) is begin null; end;
- type Index is new Long_Integer range 0 .. Long_Integer'Last;
+ type Index_T is new ptrdiff_t range 0 .. ptrdiff_t'Last;
- type Arr is array(Index range <>) of Integer;
+ type Arr is array(Index_T range <>) of Integer;
- type Rec (Size: Index := 6) is record -- { dg-warning "Storage_Error" }
+ type Rec (Size: Index_T := 6) is record -- { dg-warning "Storage_Error" }
A: Arr (0..Size);
end record;
===================================================================
@@ -1,14 +1,16 @@
-- { dg-do compile }
+with Interfaces.C; use Interfaces.C;
+
procedure Object_Overflow5 is
procedure Proc (c : Character) is begin null; end;
- type Index is new Long_Integer range 0 .. Long_Integer'Last;
+ type Index_T is new ptrdiff_t range 0 .. ptrdiff_t'Last;
- type Arr is array(Index range <>) of Character;
+ type Arr is array(Index_T range <>) of Character;
- type Rec (Size: Index := 6) is record -- { dg-warning "Storage_Error" }
+ type Rec (Size: Index_T := 6) is record -- { dg-warning "Storage_Error" }
A: Arr (0..Size);
end record;