| 1 |
-- PR ada/113893 |
| 2 |
-- Testcase by Pascal Pignard <[email protected]> |
| 3 |
|
| 4 |
-- { dg-do run } |
| 5 |
|
| 6 |
with Ada.Text_IO; |
| 7 |
with Ada.Finalization; |
| 8 |
|
| 9 |
procedure Access10 is |
| 10 |
|
| 11 |
generic |
| 12 |
type Element_Type is private; |
| 13 |
with function Image (Item : Element_Type) return String is <>; |
| 14 |
package Sanitize is |
| 15 |
type Container is new Ada.Finalization.Controlled with record |
| 16 |
Data : Element_Type; |
| 17 |
end record; |
| 18 |
overriding procedure Finalize (Object : in out Container); |
| 19 |
end Sanitize; |
| 20 |
|
| 21 |
package body Sanitize is |
| 22 |
overriding procedure Finalize (Object : in out Container) is |
| 23 |
begin |
| 24 |
Ada.Text_IO.Put_Line ("Current:" & Image (Object.Data)); |
| 25 |
end Finalize; |
| 26 |
end Sanitize; |
| 27 |
|
| 28 |
procedure Test01 is |
| 29 |
package Float_Sanitized is new Sanitize (Float, Float'Image); |
| 30 |
V : Float_Sanitized.Container; |
| 31 |
C : constant Float_Sanitized.Container := |
| 32 |
(Ada.Finalization.Controlled with 8.8); |
| 33 |
A : access Float_Sanitized.Container := |
| 34 |
new Float_Sanitized.Container'(Ada.Finalization.Controlled with 7.7); -- { dg-warning "not be finalized|named" } |
| 35 |
AC : access constant Float_Sanitized.Container := |
| 36 |
new Float_Sanitized.Container'(Ada.Finalization.Controlled with 6.6); -- { dg-warning "not be finalized|named" } |
| 37 |
begin |
| 38 |
V.Data := 9.9 + C.Data + A.Data; |
| 39 |
Ada.Text_IO.Put_Line ("Value:" & Float'Image (V.Data)); |
| 40 |
end Test01; |
| 41 |
|
| 42 |
procedure Test02 is |
| 43 |
type Float_Sanitized is new Float; |
| 44 |
V : Float_Sanitized; |
| 45 |
C : constant Float_Sanitized := (8.8); |
| 46 |
A : access Float_Sanitized := new Float_Sanitized'(7.7); |
| 47 |
AC : access constant Float_Sanitized := new Float_Sanitized'(6.6); |
| 48 |
begin |
| 49 |
V := 9.9 + C + A.all; |
| 50 |
Ada.Text_IO.Put_Line ("Value:" & Float_Sanitized'Image (V)); |
| 51 |
end Test02; |
| 52 |
|
| 53 |
begin |
| 54 |
Ada.Text_IO.Put_Line ("Test01:"); |
| 55 |
Test01; |
| 56 |
Ada.Text_IO.Put_Line ("Test02:"); |
| 57 |
Test02; |
| 58 |
end; |