Skip to content

Commit 43d51fc

Browse files
Petr BauchPetr Bauch
authored andcommitted
Fix testsuite/arrays.adb
CBMC parses the output of gnat2goto but symex never finishes unrolling.
1 parent 8252f09 commit 43d51fc

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@ package body Tree_Walk is
768768
Make_Pointer_Type (Do_Type_Reference (LHS_Element_Type));
769769
RHS_Data_Type : constant Irep :=
770770
Make_Pointer_Type (Do_Type_Reference (RHS_Element_Type));
771+
LHS_fun_call : constant Irep :=
772+
Fresh_Var_Symbol_Expr (LHS_Data_Type, "copy_fun_lhs");
771773
begin
772774
if not Can_Get_Array_Index_Type (Name (N)) then
773775
Report_Unhandled_Node_Empty (N, "Do_Array_Assignment",
@@ -836,6 +838,7 @@ package body Tree_Walk is
836838

837839
Append_Op (Ret, Make_Code_Function_Call (I_Function => Copy_Func,
838840
Arguments => Copy_Args,
841+
Lhs => LHS_fun_call,
839842
Source_Location => Sloc (N)));
840843

841844
return Ret;
@@ -3767,7 +3770,11 @@ package body Tree_Walk is
37673770
Set_Iter (Body_Loop, Make_Increment (Counter_Sym, Index_Type, 1));
37683771
Set_Lhs (Loop_Test, Counter_Sym);
37693772
Set_Rhs (Loop_Test, Param_Symbol (Len_Arg));
3773+
Set_Type (I => Loop_Test,
3774+
Value => Make_Bool_Type);
37703775
Set_Cond (Body_Loop, Loop_Test);
3776+
Set_Init (I => Body_Loop,
3777+
Value => Make_Nil (Sloc (RHS_Element_Type)));
37713778

37723779
Set_Lhs (Loop_Assign,
37733780
Make_Pointer_Index (Param_Symbol (Write_Ptr_Arg),
@@ -3831,10 +3838,12 @@ package body Tree_Walk is
38313838
Len_Arg : constant Irep := New_Irep (I_Code_Parameter);
38323839
Len_Type : constant Irep := Do_Type_Reference (Index_Type);
38333840
Func_Symbol : Symbol;
3841+
Alloc_Symbol : Symbol;
38343842
Map_Size_Str : constant String :=
38353843
Integer'Image (Integer (Array_Dup_Map.Length));
38363844
Func_Name : constant String :=
38373845
"__ada_dup_array" & Map_Size_Str (2 .. Map_Size_Str'Last);
3846+
Alloc_Name : constant String := "__new_array";
38383847
Array_Copy : constant Irep :=
38393848
Fresh_Var_Symbol_Expr (Ptr_Type, "new_array");
38403849
Array_Alloc : constant Irep :=
@@ -3843,6 +3852,9 @@ package body Tree_Walk is
38433852
Call_Inst : constant Irep := New_Irep (I_Code_Function_Call);
38443853
Call_Args : constant Irep := New_Irep (I_Argument_List);
38453854
Return_Inst : constant Irep := New_Irep (I_Code_Return);
3855+
Lhs_fun_call : constant Irep :=
3856+
Fresh_Var_Symbol_Expr (Do_Type_Reference (Element_Type),
3857+
"array_dup_fun_lhs");
38463858

38473859
begin
38483860

@@ -3866,6 +3878,8 @@ package body Tree_Walk is
38663878
Append_Argument (Call_Args, Param_Symbol (Ptr_Arg));
38673879
Append_Argument (Call_Args, Param_Symbol (Len_Arg));
38683880
Set_Arguments (Call_Inst, Call_Args);
3881+
Set_Lhs (I => Call_Inst,
3882+
Value => Lhs_fun_call);
38693883
Set_Function (Call_Inst,
38703884
Get_Array_Copy_Function (Element_Type,
38713885
Element_Type,
@@ -3883,6 +3897,13 @@ package body Tree_Walk is
38833897
Func_Symbol.Mode := Intern ("C");
38843898
Func_Symbol.Value := Body_Block;
38853899
Global_Symbol_Table.Insert (Intern (Func_Name), Func_Symbol);
3900+
-- Add allocation function to symbol table
3901+
Alloc_Symbol.SymType := Func_Type;
3902+
Alloc_Symbol.Name := Intern (Alloc_Name);
3903+
Alloc_Symbol.PrettyName := Alloc_Symbol.Name;
3904+
Alloc_Symbol.BaseName := Alloc_Symbol.Name;
3905+
Alloc_Symbol.Mode := Intern ("C");
3906+
Global_Symbol_Table.Insert (Intern (Alloc_Name), Alloc_Symbol);
38863907

38873908
-- Record it for the future:
38883909
Array_Dup_Map.Replace_Element (Map_Cursor, Symbol_Expr (Func_Symbol));

testsuite/gnat2goto/tests/arrays/test.opt

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERIFICATION SUCCESSFUL

0 commit comments

Comments
 (0)