Skip to content

Commit be63737

Browse files
Petr Bauchpetr-bauch
authored andcommitted
Extend Do_Defining_Identifier
To update the symbol table if the identifier being defined is missing.
1 parent 93fde93 commit be63737

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ package body Tree_Walk is
11911191
function Do_Defining_Identifier (E : Entity_Id) return Irep is
11921192
Sym : constant Irep := New_Irep (I_Symbol_Expr);
11931193
Result_Type : constant Irep := Do_Type_Reference (Etype (E));
1194+
Sym_Id : constant Symbol_Id := Intern (Unique_Name (E));
11941195

11951196
Is_Out_Param : constant Boolean :=
11961197
Ekind (E) in E_In_Out_Parameter | E_Out_Parameter;
@@ -1205,6 +1206,20 @@ package body Tree_Walk is
12051206
Set_Identifier (Sym, Unique_Name (E));
12061207
Set_Type (Sym, Symbol_Type);
12071208

1209+
if not Global_Symbol_Table.Contains (Sym_Id) then
1210+
declare
1211+
Variable_Symbol : Symbol;
1212+
begin
1213+
Variable_Symbol.Name := Sym_Id;
1214+
Variable_Symbol.BaseName := Sym_Id;
1215+
Variable_Symbol.PrettyName := Intern (Get_Name_String (Chars (E)));
1216+
Variable_Symbol.SymType := Symbol_Type;
1217+
Variable_Symbol.Mode := Intern ("C");
1218+
Variable_Symbol.Value := Make_Nil (Sloc (E));
1219+
Global_Symbol_Table.Insert (Sym_Id, Variable_Symbol);
1220+
end;
1221+
end if;
1222+
12081223
if Is_Out_Param then
12091224
return Deref : constant Irep := New_Irep (I_Dereference_Expr) do
12101225
Set_Type (Deref, Result_Type);

0 commit comments

Comments
 (0)