Skip to content

Commit 58b3137

Browse files
Petr BauchPetr Bauch
authored andcommitted
Fix computation of member size
Move to hexa-convertion.
1 parent 3bc2d5a commit 58b3137

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4235,10 +4235,16 @@ package body Tree_Walk is
42354235
Source_Location => Source_Loc);
42364236

42374237
-- NEW VARS FOR MALLOC ALLOCATION
4238-
Type_Width : constant Integer :=
4239-
Positive (UI_To_Int (Esize (Element_Type)));
4238+
-- Type_Width : constant Integer :=
4239+
-- Positive (UI_To_Int (Esize (Element_Type)));
42404240
Member_Size : constant Irep :=
4241-
(Make_Integer_Constant (Type_Width, Index_Type));
4241+
Make_Constant_Expr (Source_Location => Source_Loc,
4242+
I_Type => Len_Type,
4243+
Range_Check => False,
4244+
Value =>
4245+
Convert_Uint_To_Hex (Value => Esize (Element_Type) / 8,
4246+
Bit_Width => 32));
4247+
-- (Make_Integer_Constant (Type_Width, Index_Type));
42424248
begin
42434249
-- Create body (allocate and then call array_copy)
42444250
-- --------------------------------------------------
@@ -4248,7 +4254,7 @@ package body Tree_Walk is
42484254
Make_Op_Mul (
42494255
Lhs => Member_Size,
42504256
Rhs => Param_Symbol (Len_Param),
4251-
I_Type => Make_Integer_Type,
4257+
I_Type => Len_Type,
42524258
Source_Location => Source_Loc)),
42534259
Body_Block, 0);
42544260
-- --------------------------------------------------

0 commit comments

Comments
 (0)