Skip to content

Commit 5d2e7c5

Browse files
committed
Process a subprogram's parameters before processing its body
PR 220 introduced a regression. It entered subprogram parameters into the symbol table before processing their declaration causing the processing of a subprogram specification to fail. This could happen if a subprogram body was declared without a separate declaration (perfectly legal to do this in Ada). This change removes the code from PR 220 and ensures a subprogram specification is processed before its body.
1 parent ff9b6b3 commit 5d2e7c5

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,6 @@ package body Tree_Walk is
11921192
function Do_Defining_Identifier (E : Entity_Id) return Irep is
11931193
Sym : constant Irep := New_Irep (I_Symbol_Expr);
11941194
Result_Type : constant Irep := Do_Type_Reference (Etype (E));
1195-
Sym_Id : constant Symbol_Id := Intern (Unique_Name (E));
11961195

11971196
Is_Out_Param : constant Boolean :=
11981197
Ekind (E) in E_In_Out_Parameter | E_Out_Parameter;
@@ -1207,13 +1206,6 @@ package body Tree_Walk is
12071206
Set_Identifier (Sym, Unique_Name (E));
12081207
Set_Type (Sym, Symbol_Type);
12091208

1210-
if not Global_Symbol_Table.Contains (Sym_Id) then
1211-
New_Object_Symbol_Entry (Object_Name => Sym_Id,
1212-
Object_Type => Symbol_Type,
1213-
Object_Init_Value => Make_Nil (Sloc (E)),
1214-
A_Symbol_Table => Global_Symbol_Table);
1215-
end if;
1216-
12171209
if Is_Out_Param then
12181210
return Deref : constant Irep := New_Irep (I_Dereference_Expr) do
12191211
Set_Type (Deref, Result_Type);
@@ -4118,9 +4110,7 @@ package body Tree_Walk is
41184110
procedure Do_Subprogram_Body (N : Node_Id) is
41194111
Proc_Name : constant Symbol_Id :=
41204112
Intern (Unique_Name (Defining_Entity (N)));
4121-
-- Intern (Unique_Name (Corresponding_Spec (N)));
41224113

4123-
Proc_Body : constant Irep := Do_Subprogram_Or_Block (N);
41244114
Proc_Symbol : Symbol;
41254115
begin
41264116
if not Global_Symbol_Table.Contains (Proc_Name) then
@@ -4140,7 +4130,7 @@ package body Tree_Walk is
41404130
Proc_Symbol := Global_Symbol_Table (Proc_Name);
41414131

41424132
-- Compile the subprogram body and update its entry in the symbol table.
4143-
Proc_Symbol.Value := Proc_Body;
4133+
Proc_Symbol.Value := Do_Subprogram_Or_Block (N);
41444134
Global_Symbol_Table.Replace (Proc_Name, Proc_Symbol);
41454135
end Do_Subprogram_Body;
41464136

0 commit comments

Comments
 (0)