Skip to content

Commit 1b3ba7f

Browse files
committed
Implement handling the address attribute
by returning address-of expression.
1 parent a80baf8 commit 1b3ba7f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,12 @@ package body Tree_Walk is
384384
and then List_Length (Expressions (N)) = 1),
385385
Post => Kind (Do_Attribute_Succ_Discrete'Result) in Class_Expr;
386386

387+
function Do_Attribute_Address (N : Node_Id) return Irep
388+
with Pre => (Nkind (N) = N_Attribute_Reference
389+
and then Get_Attribute_Id (Attribute_Name (N)) =
390+
Attribute_Address),
391+
Post => Kind (Do_Attribute_Address'Result) in Class_Expr;
392+
387393
function Make_Malloc_Function_Call_Expr (Num_Elem : Irep;
388394
Element_Type_Size : Uint;
389395
Source_Loc : Source_Ptr)
@@ -1358,6 +1364,12 @@ package body Tree_Walk is
13581364
I_Type => Result_Type);
13591365
end Do_Attribute_Succ_Discrete;
13601366

1367+
function Do_Attribute_Address (N : Node_Id) return Irep is
1368+
Arg_Expr : constant Irep := Do_Expression (Prefix (N));
1369+
begin
1370+
return Make_Address_Of (Arg_Expr);
1371+
end Do_Attribute_Address;
1372+
13611373
-------------------
13621374
-- Do_Expression --
13631375
-------------------
@@ -1399,6 +1411,8 @@ package body Tree_Walk is
13991411
return Do_Attribute_Pred_Discrete (N);
14001412
when Attribute_Succ =>
14011413
return Do_Attribute_Succ_Discrete (N);
1414+
when Attribute_Address =>
1415+
return Do_Attribute_Address (N);
14021416
when others =>
14031417
return Report_Unhandled_Node_Irep (N, "Do_Expression",
14041418
"Unknown attribute");

0 commit comments

Comments
 (0)