Skip to content

Commit de7ab01

Browse files
Petr BauchPetr Bauch
authored andcommitted
Fix based on comments
1 parent 1e41f98 commit de7ab01

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

gnat2goto/driver/driver.adb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ package body Driver is
257257
end;
258258

259259
if not Add_Start then
260+
-- If the compilation unit is not a subprogram body then there is
261+
-- no function/procedure to call
262+
-- CBMC does not like that so we add cprover_start with empty body
260263
Start_Symbol.Name := Start_Name;
261264
Start_Symbol.PrettyName := Start_Name;
262265
Start_Symbol.BaseName := Start_Name;

gnat2goto/driver/tree_walk.adb

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ package body Tree_Walk is
391391
procedure Process_Declarations (L : List_Id; Block : Irep);
392392
-- Processes the declarations and is used for both a package specification
393393
-- where only basic declarations are allowed (no subprogram bodies etc.)
394-
-- and declarative parts where such declaratios are allowed.
394+
-- and declarative parts where subprogram bodies etc. may be declared.
395395
-- The Gnat front end will check that only allowed declarations are used
396396
-- where only basic declarations permitted.
397397
-- Process_Declarations is a procedure rather than a function like its
@@ -1596,11 +1596,6 @@ package body Tree_Walk is
15961596
end Create_Dummy_Irep;
15971597

15981598
function Do_Expression (N : Node_Id) return Irep is
1599-
procedure Warn_Unhandled_Expression (M : String);
1600-
procedure Warn_Unhandled_Expression (M : String) is
1601-
begin
1602-
Put_Line (Standard_Error, "Warning: " & M & "expressions unhandled");
1603-
end Warn_Unhandled_Expression;
16041599
begin
16051600
Declare_Itype (Etype (N));
16061601
case Nkind (N) is
@@ -1616,14 +1611,14 @@ package body Tree_Walk is
16161611
when Attribute_Access => return Do_Address_Of (N);
16171612
when Attribute_Length => return Do_Array_Length (N);
16181613
when Attribute_Range =>
1619-
Warn_Unhandled_Expression ("Range attribute");
1620-
return Create_Dummy_Irep;
1614+
return Report_Unhandled_Node_Irep (N, "Do_Expression",
1615+
"Range attribute");
16211616
when Attribute_First =>
1622-
Warn_Unhandled_Expression ("First attribute");
1623-
return Create_Dummy_Irep;
1617+
return Report_Unhandled_Node_Irep (N, "Do_Expression",
1618+
"First attribute");
16241619
when Attribute_Last =>
1625-
Warn_Unhandled_Expression ("Last attribute");
1626-
return Create_Dummy_Irep;
1620+
return Report_Unhandled_Node_Irep (N, "Do_Expression",
1621+
"Last attribute");
16271622
when others =>
16281623
return Report_Unhandled_Node_Irep (N, "Do_Expression",
16291624
"Unknown attribute");
@@ -1634,20 +1629,20 @@ package body Tree_Walk is
16341629
when N_Indexed_Component => return Do_Indexed_Component (N);
16351630
when N_Slice => return Do_Slice (N);
16361631
when N_In =>
1637-
Warn_Unhandled_Expression ("In");
1638-
return Create_Dummy_Irep;
1632+
return Report_Unhandled_Node_Irep (N, "Do_Expression",
1633+
"In");
16391634
when N_Real_Literal => return Do_Real_Constant (N);
16401635
when N_If_Expression => return Do_If_Expression (N);
16411636
when N_And_Then => return Do_And_Then (N);
16421637
when N_Or_Else =>
1643-
Warn_Unhandled_Expression ("Or else");
1644-
return Create_Dummy_Irep;
1638+
return Report_Unhandled_Node_Irep (N, "Do_Expression",
1639+
"Or else");
16451640
when N_Qualified_Expression =>
1646-
Warn_Unhandled_Expression ("Qualified");
1647-
return Create_Dummy_Irep;
1641+
return Report_Unhandled_Node_Irep (N, "Do_Expression",
1642+
"Qualified");
16481643
when N_Quantified_Expression =>
1649-
Warn_Unhandled_Expression ("Quantified");
1650-
return Create_Dummy_Irep;
1644+
return Report_Unhandled_Node_Irep (N, "Do_Expression",
1645+
"Quantified");
16511646
when others =>
16521647
return Report_Unhandled_Node_Irep (N, "Do_Expression",
16531648
"Unknown expression kind");
@@ -4026,8 +4021,8 @@ package body Tree_Walk is
40264021
-- populate the symbol table instead.
40274022
Register_Subprogram_Specification (Specification (N));
40284023
end if;
4029-
-- Todo aspect_specification
4030-
-- Now the subprogram should registered in the stmbol table
4024+
-- Todo aspect_specification, i.e. pre/post-conditions
4025+
-- Now the subprogram should registered in the symbol table
40314026
-- whether a separate declaration was provided or not.
40324027
if not Global_Symbol_Table.Contains (Proc_Name) then
40334028
Report_Unhandled_Node_Empty (N, "Do_Subprogram_Body",
@@ -4338,10 +4333,10 @@ package body Tree_Walk is
43384333
if Defining_Entity (N) = Stand.Standard_Standard or else
43394334
Unit_Name = "system%s"
43404335
then
4336+
-- At the moment Standard or System are not processed: TODO
43414337
null;
4342-
-- At the moment Standard or System are not processed - to be done
43434338
else
4344-
4339+
-- Handle all other withed library unit declarations
43454340
case Nkind (N) is
43464341
when N_Subprogram_Body =>
43474342
if Acts_As_Spec (N) then

0 commit comments

Comments
 (0)