Skip to content

Commit 305497c

Browse files
committed
Refactor handle_representation_clause
fewer nested-ifs, fewer int<->uint conversions.
1 parent ae0de58 commit 305497c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,21 +4589,22 @@ package body Tree_Walk is
45894589
procedure Handle_Representation_Clause (N : Node_Id) is
45904590
Attr_Id : constant String := Get_Name_String (Chars (N));
45914591
Target_Name : constant Irep := Do_Identifier (Name (N));
4592-
Entity_Esize : constant Integer :=
4593-
Integer (UI_To_Int (Esize (Entity (N))));
4592+
Entity_Esize : constant Uint := Esize (Entity (N));
45944593
Target_Type_Irep : constant Irep :=
45954594
Follow_Symbol_Type (Get_Type (Target_Name), Global_Symbol_Table);
4595+
Expression_Value : constant Uint := Intval (Expression (N));
45964596
begin
4597-
if Kind (Target_Type_Irep) in Class_Type then
4598-
if Attr_Id = "size" then
4599-
4600-
-- Just check that the front-end already applied this size
4601-
-- clause, i .e. that the size of type-irep we already had
4602-
-- equals the entity type this clause is applied to (and the
4603-
-- size specified in this clause).
4604-
pragma Assert (Entity_Esize = Get_Width (Target_Type_Irep)
4605-
and Entity_Esize =
4606-
Integer (UI_To_Int (Intval (Expression (N)))));
4597+
pragma Assert (Kind (Target_Type_Irep) in Class_Type);
4598+
if Attr_Id = "size" then
4599+
4600+
-- Just check that the front-end already applied this size
4601+
-- clause, i .e. that the size of type-irep we already had
4602+
-- equals the entity type this clause is applied to (and the
4603+
-- size specified in this clause).
4604+
pragma Assert (Entity_Esize =
4605+
UI_From_Int (Int (Get_Width (Target_Type_Irep)))
4606+
and Entity_Esize = Expression_Value);
4607+
return;
46074608
return;
46084609
end if;
46094610
end if;

0 commit comments

Comments
 (0)