Skip to content

Commit 9900266

Browse files
author
Sonny Martin
committed
Add support for N_Block_Statement node
1 parent 22bbe07 commit 9900266

File tree

5 files changed

+62
-15
lines changed

5 files changed

+62
-15
lines changed

gnat2goto/driver/tree_walk.adb

+14-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ package body Tree_Walk is
146146
with Pre => Nkind (N) = N_Loop_Statement,
147147
Post => Kind (Do_Loop_Statement'Result) in Class_Code;
148148

149+
function Do_N_Block_Statement (N : Node_Id) return Irep
150+
with Pre => Nkind (N) = N_Block_Statement,
151+
Post => Kind (Do_N_Block_Statement'Result) = I_Code_Block;
152+
149153
procedure Do_Object_Declaration (N : Node_Id; Block : Irep)
150154
with Pre => Nkind (N) = N_Object_Declaration
151155
and then Kind (Block) = I_Code_Block;
@@ -1949,6 +1953,15 @@ package body Tree_Walk is
19491953
return Loop_Wrapper;
19501954
end Do_Loop_Statement;
19511955

1956+
-----------------------------------------
1957+
-- Do_N_Block_Statement (nested declares)
1958+
-----------------------------------------
1959+
1960+
function Do_N_Block_Statement (N : Node_Id) return Irep is
1961+
begin
1962+
return Do_Subprogram_Or_Block (N);
1963+
end Do_N_Block_Statement;
1964+
19521965
---------------
19531966
-- Do_Pragma --
19541967
---------------
@@ -4024,7 +4037,7 @@ package body Tree_Walk is
40244037
Append_Op (Block, Do_Loop_Statement (N));
40254038

40264039
when N_Block_Statement =>
4027-
Warn_Unhandled_Construct (Statement, "block");
4040+
Append_Op (Block, Do_N_Block_Statement (N));
40284041

40294042
when N_Handled_Sequence_Of_Statements => -- this seems incorrct
40304043
-- It should be block_statement

testsuite/gnat2goto/tests/statement_new_block_N_Block_Statement/Statement_Block.adb

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
function Statement_Block return Integer is
2+
Var1 : Integer :=1;
3+
Var2 : Integer;
4+
5+
function Sum_Plus_Three(Left, Right : Integer) return Integer is
6+
Local1 : Integer;
7+
begin
8+
declare
9+
Local2 : Integer := 1;
10+
begin
11+
Local1 := Local2 + Var1 + 1;
12+
Pragma Assert (Local1=3);
13+
end;
14+
return (Left + Right + Local1);
15+
end Sum_Plus_Three;
16+
17+
begin
18+
----------------------------------------
19+
-- the below nested function call works, but is out of scope
20+
-- and nested functions are not yet fully supported / tested
21+
----------------------------------------
22+
-- Var1 := Sum_Plus_Three(3,4);
23+
-- pragma Assert (Var1=10);
24+
----------------------------------------
25+
26+
declare
27+
Var3 : Integer :=2;
28+
begin
29+
Var2 := Var3;
30+
pragma Assert (Var2=2);
31+
declare
32+
Var4 : Integer := Var3;
33+
begin
34+
Var2 := Var4 + Var2;
35+
Pragma Assert (Var2=4);
36+
end;
37+
end;
38+
39+
declare
40+
Var5 : Integer := 6;
41+
begin
42+
Var2 := Var5 + Var2;
43+
end;
44+
45+
pragma Assert (Var2=10);
46+
return Var2;
47+
end Statement_Block;

testsuite/gnat2goto/tests/statement_new_block_N_Block_Statement/test.opt

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERIFICATION SUCCESSFUL

0 commit comments

Comments
 (0)