Skip to content

Commit 6c5edcd

Browse files
Merge pull request #253 from tjj2017/new_derived_type_checks
New derived type checks replaces PR #213
2 parents a10a654 + 7a5c196 commit 6c5edcd

File tree

8 files changed

+41
-1
lines changed

8 files changed

+41
-1
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,9 +1487,11 @@ package body Tree_Walk is
14871487
-- (via `Register_Type_Declaration') when its
14881488
-- private or incomplete_type_declaration was processed.
14891489
-- If it has no private declaration or the Incomplete_View is not
1490-
-- present then the full_type_declaration has to be registered
1490+
-- present or it is a derived_type_definition
1491+
-- then the full_type_declaration has to be registered
14911492
if not (Has_Private_Declaration (E)
14921493
or else Present (Incomplete_View (N)))
1494+
or else Nkind (Type_Definition (N)) = N_Derived_Type_Definition
14931495
then
14941496
Do_Type_Declaration (New_Type, E);
14951497

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
with Private_Type; use Private_Type;
2+
procedure Derived_Private_Type is
3+
type Derived_Priv is new Priv;
4+
V_Priv : Priv := Priv_Const;
5+
V_D_Priv : Derived_Priv := Derived_Priv (Priv_Const);
6+
begin
7+
pragma Assert (Derived_Priv (V_Priv) = V_D_Priv);
8+
null;
9+
end Derived_Private_Type;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package Private_Type is
2+
type Priv is private;
3+
Priv_Const : constant Priv;
4+
private
5+
type Priv is new Integer range 1 .. 23;
6+
Priv_Const : constant Priv := 17;
7+
end Private_Type;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[1] file derived_private_type.adb line 7 assertion: SUCCESS
2+
VERIFICATION SUCCESSFUL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from test_support import *
2+
3+
prove()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
procedure Derived_Types is
2+
type My_Int is range -23 .. 23;
3+
type My_Real is new Float;
4+
5+
begin
6+
pragma Assert (0 in My_Int);
7+
pragma Assert (11.0 in My_Real);
8+
pragma Assert (My_Int'Succ (22) = 23);
9+
null;
10+
end Derived_Types;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[1] file derived_types.adb line 6 assertion: SUCCESS
2+
[2] file derived_types.adb line 7 assertion: SUCCESS
3+
[3] file derived_types.adb line 8 assertion: SUCCESS
4+
VERIFICATION SUCCESSFUL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from test_support import *
2+
3+
prove()

0 commit comments

Comments
 (0)