Skip to content

Commit e47f6d2

Browse files
committed
Add support to access-to-object type
by simply creating a pointer-to type. Note: this somehow was not triggered by our existing primitive-pointer test (which had `int*`).
1 parent d57ab6e commit e47f6d2

File tree

10 files changed

+38
-36
lines changed

10 files changed

+38
-36
lines changed

experiments/golden-results/StratoX-summary.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ Calling function: Process_Pragma_Declaration
2828
Error message: Unknown pragma: volatile_full_access
2929
Nkind: N_Pragma
3030
--
31-
Occurs: 57 times
32-
Calling function: Do_Type_Definition
33-
Error message: Access type unsupported
34-
Nkind: N_Access_To_Object_Definition
35-
--
3631
Occurs: 22 times
3732
Calling function: Do_Expression
3833
Error message: First of string unsupported
@@ -1755,7 +1750,7 @@ Error detected at REDACTED
17551750
--
17561751
Occurs: 3 times
17571752
+===========================GNAT BUG DETECTED==============================+
1758-
| GNU Ada (ada2goto) Assert_Failure tree_walk.adb:989 |
1753+
| GNU Ada (ada2goto) Assert_Failure tree_walk.adb:992 |
17591754
Error detected at REDACTED
17601755
--
17611756
Occurs: 2 times

experiments/golden-results/ksum-summary.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ Calling function: Process_Pragma_Declaration
33
Error message: Unsupported pragma: Suppress initialization
44
Nkind: N_Pragma
55
--
6-
Occurs: 1 times
7-
Calling function: Do_Type_Definition
8-
Error message: Access type unsupported
9-
Nkind: N_Access_To_Object_Definition
10-
--
116
Occurs: 41 times
127
Redacted compiler error message:
138
file "REDACTED" not found

experiments/golden-results/libkeccak-summary.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ Calling function: Process_Declaration
1818
Error message: Use type clause declaration
1919
Nkind: N_Use_Type_Clause
2020
--
21-
Occurs: 19 times
22-
Calling function: Do_Type_Definition
23-
Error message: Access type unsupported
24-
Nkind: N_Access_To_Object_Definition
25-
--
2621
Occurs: 18 times
2722
Calling function: Process_Pragma_Declaration
2823
Error message: Unsupported pragma: Suppress initialization

experiments/golden-results/libsparkcrypto-summary.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ Error message: Non-literal bound unsupported
4949
Nkind: N_Defining_Identifier
5050
--
5151
Occurs: 24 times
52-
Calling function: Do_Type_Definition
53-
Error message: Access type unsupported
54-
Nkind: N_Access_To_Object_Definition
55-
--
56-
Occurs: 24 times
5752
Calling function: Process_Declaration
5853
Error message: size clause not applied by the front-end
5954
Nkind: N_Attribute_Definition_Clause

experiments/golden-results/muen-summary.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ Calling function: Process_Declaration
33
Error message: Use type clause declaration
44
Nkind: N_Use_Type_Clause
55
--
6-
Occurs: 105 times
7-
Calling function: Do_Type_Definition
8-
Error message: Access type unsupported
9-
Nkind: N_Access_To_Object_Definition
10-
--
116
Occurs: 56 times
127
Calling function: Process_Declaration
138
Error message: size clause not applied by the front-end

gnat2goto/driver/tree_walk.adb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ package body Tree_Walk is
407407
with Pre => Nkind (N) in N_Access_Function_Definition |
408408
N_Access_Procedure_Definition;
409409

410+
function Do_Access_To_Object_Definition (N : Node_Id) return Irep
411+
with Pre => Nkind (N) = N_Access_To_Object_Definition;
412+
410413
function Get_No_Return_Check return Irep;
411414

412415
function Make_Malloc_Function_Call_Expr (Num_Elem : Irep;
@@ -5099,8 +5102,7 @@ package body Tree_Walk is
50995102
when N_Access_Procedure_Definition =>
51005103
return Do_Access_Function_Definition (N);
51015104
when N_Access_To_Object_Definition =>
5102-
return Report_Unhandled_Node_Type (N, "Do_Type_Definition",
5103-
"Access type unsupported");
5105+
return Do_Access_To_Object_Definition (N);
51045106
when others =>
51055107
return Report_Unhandled_Node_Type (N, "Do_Type_Definition",
51065108
"Unknown expression kind");
@@ -6281,6 +6283,17 @@ package body Tree_Walk is
62816283
Knr => False));
62826284
end Do_Access_Function_Definition;
62836285

6286+
function Do_Access_To_Object_Definition (N : Node_Id) return Irep
6287+
is
6288+
Sub_Indication : constant Node_Id := Subtype_Indication (N);
6289+
Under_Type : constant Node_Id := Etype
6290+
(if Nkind (Sub_Indication) = N_Subtype_Indication
6291+
then Subtype_Mark (Sub_Indication)
6292+
else Sub_Indication);
6293+
begin
6294+
return Make_Pointer_Type (Do_Type_Reference (Under_Type));
6295+
end Do_Access_To_Object_Definition;
6296+
62846297
function Get_No_Return_Check return Irep is
62856298
No_Return_Check_Symbol : constant Irep := Symbol_Expr
62866299
(Get_Ada_Check_Symbol
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
procedure Main is
2+
type Day_Of_Month is range 1 .. 31;
3+
type Day_Of_Month_Access is access all Day_Of_Month;
4+
5+
-- funny case where the subtype-indication has subtype-mark
6+
type C_String_Ptr is access String (1 .. Positive'Last);
7+
8+
A : aliased Day_Of_Month;
9+
Ptr1 : Day_Of_Month_Access := A'Access;
10+
Ptr2 : Day_Of_Month_Access := A'Access;
11+
begin
12+
Ptr1.all := 2;
13+
pragma Assert (A=2); -- should succeed
14+
Ptr2.all := 5;
15+
pragma Assert (Ptr1.all=4); -- should fail
16+
end;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[main.assertion.1] line 13 assertion A=2: SUCCESS
2+
[main.assertion.2] line 15 assertion Ptr1.all=4: FAILURE
3+
VERIFICATION FAILED
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: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
Standard_Output from gnat2goto null_pointer:
2-
----------At: Do_Type_Definition----------
3-
----------Access type unsupported----------
4-
N_Access_To_Object_Definition (Node_Id=2262) (source)
5-
Parent = N_Full_Type_Declaration (Node_Id=2263)
6-
Sloc = 8232 null_pointer.adb:2:15
7-
Subtype_Indication = N_Identifier "integer" (Node_Id=2261)
8-
91
[null_pointer.assertion.1] line 5 assertion X = null: SUCCESS
102
VERIFICATION SUCCESSFUL

0 commit comments

Comments
 (0)