Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion experiments/golden-results/SPARK-tetris-summary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ Raw compiler error message:
--
Occurs: 5 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Constraint_Error Symbol_Table_Info.Symbol_Maps.Constant_Reference: key not in map|
| GNU Ada (ada2goto) Assert_Failure failed postcondition from arrays.ads:52|
Error detected at REDACTED
22 changes: 11 additions & 11 deletions experiments/golden-results/StratoX-summary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ Error message: Unsupported pragma: Check
Nkind: N_Pragma
--
Occurs: 8 times
Calling function: Process_Pragma_Declaration
Error message: Unsupported pragma: Obsolescent
Nkind: N_Pragma
--
Occurs: 7 times
Calling function: Do_Type_Reference
Error message: Type of type not a type
Nkind: N_Defining_Identifier
--
Occurs: 8 times
Calling function: Process_Pragma_Declaration
Error message: Unsupported pragma: Obsolescent
Nkind: N_Pragma

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the golden results changes appear to be just things moving around for some weird reason. Very few actual changes.

Copy link
Contributor

@chrisr-diffblue chrisr-diffblue Jan 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like a move, but actually its because "Do_Type_Reference" went from 7 -> 8 times...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisr-diffblue Yes, I believe this is because some of the nodes that we now handle were not handled before. This means that some nodes in these projects now propagate, and they might result into some previously unreported errors showing up.

Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue Jan 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisr-diffblue Keep in mind that the changes made in this PR cause gnat2goto to not crash in some circumstances where it would’ve crashed before, so it’s producing more output and potentially some additional missing but unrelated features as well.

--
Occurs: 6 times
Calling function: Process_Declaration
Error message: Use type clause declaration
Expand Down Expand Up @@ -108,6 +108,11 @@ Calling function: Do_Itype_Definition
Error message: Unknown Ekind
Nkind: N_Defining_Identifier
--
Occurs: 2 times
Calling function: Do_Itype_Integer_Subtype
Error message: Non-literal bound unsupported
Nkind: N_Defining_Identifier
--
Occurs: 1 times
Calling function: Do_Base_Range_Constraint
Error message: unsupported lower range kind
Expand All @@ -134,11 +139,6 @@ Error message: function entity not defining identifier
Nkind: N_Defining_Operator_Symbol
--
Occurs: 1 times
Calling function: Do_Itype_Integer_Subtype
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one where we get an extra occurence

Error message: Non-literal bound unsupported
Nkind: N_Defining_Identifier
--
Occurs: 1 times
Calling function: Do_Op_Expon
Error message: Exponentiation unhandled for non mod types at the moment
Nkind: N_Op_Expon
Expand Down Expand Up @@ -1718,7 +1718,7 @@ Occurs: 10 times
| GNU Ada (ada2goto) Assert_Failure sinfo.adb:495 |
Error detected at REDACTED
--
Occurs: 9 times
Occurs: 8 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Constraint_Error Symbol_Table_Info.Symbol_Maps.Constant_Reference: key not in map|
Error detected at REDACTED
Expand Down
52 changes: 26 additions & 26 deletions experiments/golden-results/muen-summary.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Occurs: 160 times
Occurs: 161 times
Calling function: Process_Declaration
Error message: Use type clause declaration
Nkind: N_Use_Type_Clause
Expand Down Expand Up @@ -38,11 +38,21 @@ Calling function: Process_Pragma_Declaration
Error message: Unsupported pragma: Precondition
Nkind: N_Pragma
--
Occurs: 6 times
Occurs: 7 times
Calling function: Do_Type_Reference
Error message: Type of type not a type
Nkind: N_Defining_Identifier
--
Occurs: 5 times
Calling function: Do_Itype_Integer_Subtype
Error message: Non-literal bound unsupported
Nkind: N_Defining_Identifier
--
Occurs: 5 times
Calling function: Process_Pragma_Declaration
Error message: Unsupported pragma: Postcondition
Nkind: N_Pragma
--
Occurs: 4 times
Calling function: Do_Expression
Error message: First of string unsupported
Expand All @@ -53,16 +63,16 @@ Calling function: Do_Full_Type_Declaration
Error message: type not in symbol table after declaration
Nkind: N_Full_Type_Declaration
--
Occurs: 4 times
Calling function: Do_Itype_Integer_Subtype
Error message: Non-literal bound unsupported
Nkind: N_Defining_Identifier
--
Occurs: 3 times
Calling function: Do_Private_Type_Declaration
Error message: Tagged type declaration unsupported
Nkind: N_Private_Type_Declaration
--
Occurs: 3 times
Calling function: Process_Statement
Error message: Unknown expression kind
Nkind: N_Object_Renaming_Declaration
--
Occurs: 2 times
Calling function: Do_Aggregate_Literal
Error message: Unhandled aggregate kind: E_PRIVATE_TYPE
Expand All @@ -83,11 +93,6 @@ Calling function: Process_Pragma_Declaration
Error message: Unsupported pragma: Check
Nkind: N_Pragma
--
Occurs: 2 times
Calling function: Process_Statement
Error message: Unknown expression kind
Nkind: N_Object_Renaming_Declaration
--
Occurs: 1 times
Calling function: Do_Aggregate_Literal
Error message: Unhandled aggregate kind: E_RECORD_TYPE_WITH_PRIVATE
Expand All @@ -113,11 +118,6 @@ Calling function: Do_Op_Expon
Error message: Exponentiation unhandled for non mod types at the moment
Nkind: N_Op_Expon
--
Occurs: 1 times
Calling function: Process_Pragma_Declaration
Error message: Unsupported pragma: Postcondition
Nkind: N_Pragma
--
Occurs: 291 times
Redacted compiler error message:
violation of restriction "REDACTED"
Expand Down Expand Up @@ -2968,24 +2968,24 @@ Occurs: 12 times
| GNU Ada (ada2goto) Assert_Failure sinfo.adb:495 |
Error detected at REDACTED
--
Occurs: 6 times
Occurs: 3 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Constraint_Error Symbol_Table_Info.Symbol_Maps.Constant_Reference: key not in map|
| GNU Ada (ada2goto) Assert_Failure failed precondition from goto_utils.ads:147|
Error detected at REDACTED
--
Occurs: 3 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Assert_Failure failed precondition from goto_utils.ads:147|
| GNU Ada (ada2goto) Constraint_Error Symbol_Table_Info.Symbol_Maps.Constant_Reference: key not in map|
Error detected at REDACTED
--
Occurs: 2 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Assert_Failure failed precondition from ireps.ads:1784|
Error detected at REDACTED
--
Occurs: 1 times
Occurs: 2 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Assert_Failure failed precondition from ireps.ads:1784|
| GNU Ada (ada2goto) Assert_Failure sinfo.adb:2534 |
Error detected at REDACTED
--
Occurs: 1 times
Expand Down Expand Up @@ -3180,22 +3180,22 @@ Error detected at REDACTED
--
Occurs: 1 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Assert_Failure failed precondition from tree_walk.ads:106|
| GNU Ada (ada2goto) Assert_Failure failed precondition from ireps.ads:1784|
Error detected at REDACTED
--
Occurs: 1 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Assert_Failure sinfo.adb:394 |
| GNU Ada (ada2goto) Assert_Failure failed precondition from tree_walk.ads:106|
Error detected at REDACTED
--
Occurs: 1 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Assert_Failure sinfo.adb:394 |
| GNU Ada (ada2goto) Assert_Failure sinfo.adb:2534 |
Error detected at REDACTED
--
Occurs: 1 times
+===========================GNAT BUG DETECTED==============================+
| GNU Ada (ada2goto) Assert_Failure sinfo.adb:394 |
| GNU Ada (ada2goto) Assert_Failure sinfo.adb:2534 |
Error detected at REDACTED
--
Occurs: 1 times
Expand Down
29 changes: 27 additions & 2 deletions gnat2goto/driver/gnat2goto_itypes.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ with Range_Check; use Range_Check;
with Symbol_Table_Info; use Symbol_Table_Info;
with Tree_Walk; use Tree_Walk;
with Follow; use Follow;
with Arrays; use Arrays;

package body Gnat2goto_Itypes is

Expand Down Expand Up @@ -84,6 +85,7 @@ package body Gnat2goto_Itypes is
-- might become the only way to get a type definition.
return (case Ekind (N) is
when E_Array_Subtype => Do_Itype_Array_Subtype (N),
when E_Array_Type => Do_Itype_Array_Type (N),
when E_String_Literal_Subtype => Do_Itype_String_Literal_Subtype (N),
when E_Signed_Integer_Subtype => Do_Itype_Integer_Subtype (N),
when E_Record_Subtype => Do_Itype_Record_Subtype (N),
Expand All @@ -96,13 +98,36 @@ package body Gnat2goto_Itypes is
"Unknown Ekind"));
end Do_Itype_Definition;

----------------------------
-- Do_Itype_Array_Type --
----------------------------

function Do_Itype_Array_Type (E : Entity_Id) return Irep is
Var : constant Node_Id :=

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should get a better name than Var. I don’t know, something like Type_Of_Underlyign_Array or something of the sort?

Object_Definition (Associated_Node_For_Itype (E));
begin
case Nkind (Var) is
when N_Constrained_Array_Definition =>
return Do_Constrained_Array_Definition (Var);
when N_Unconstrained_Array_Definition =>
return Do_Unconstrained_Array_Definition (Var);
when others =>
return Report_Unhandled_Node_Irep
(E, "Do_Itype_Array_Type",
"Unknown array type " & Node_Kind'Image (Nkind (Var)));
end case;
end Do_Itype_Array_Type;

----------------------------
-- Do_Itype_Array_Subtype --
----------------------------

function Do_Itype_Array_Subtype (N : Node_Id) return Irep is
(Make_Symbol_Type
(Identifier => Unique_Name (Etype (N))));
begin
Declare_Itype (Etype (N));
return Make_Symbol_Type
(Identifier => Unique_Name (Etype (N)));
end Do_Itype_Array_Subtype;

-------------------------------------
-- Do_Itype_String_Literal_Subtype --
Expand Down
3 changes: 3 additions & 0 deletions gnat2goto/driver/gnat2goto_itypes.ads
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ private
function Do_Modular_Integer_Subtype (N : Entity_Id) return Irep
with Pre => Is_Itype (N) and then Ekind (N) = E_Modular_Integer_Subtype;

function Do_Itype_Array_Type (E : Entity_Id) return Irep
with Pre => Is_Itype (E) and Ekind (E) = E_Array_Type;

end Gnat2goto_Itypes;
1 change: 1 addition & 0 deletions gnat2goto/driver/tree_walk.adb
Original file line number Diff line number Diff line change
Expand Up @@ -5118,6 +5118,7 @@ package body Tree_Walk is
(if Ekind (E) = E_Access_Subtype then Etype (E) else E);
Type_Id : constant Symbol_Id := Intern (Type_Name);
begin
Declare_Itype (E);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the important bit; We now just proactively declare (possible) Itypes whenever we see them (Declare_Itype will take non-Itypes and just ignore them). This way, at least theoretically, we should always have types in the symbol table as soon as we reference them.

if Global_Symbol_Table.Contains (Type_Id) then
if Kind (Global_Symbol_Table.Element (Type_Id).SymType) in Class_Type
then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
-- see also test "arrays_multidimensional_declaration_failure1"
procedure Arrays_Declaration_Failure1 is
-- ERROR, "GNAT BUG DETECTED" " GNU Ada (ada2goto) Constraint_Error Symbol_Table_Info.Symbol_Maps.Constant_Reference: key not in map|"
A1 : Array (1..3) of Integer;

-- ERROR, "GNAT BUG DETECTED" " GNU Ada (ada2goto) Constraint_Error Symbol_Table_Info.Symbol_Maps.Constant_Reference: key not in map|"
A2 : Array (1..3) of Integer := (1,2,3);
begin
null;
A1 (1) := 1;
pragma Assert (A1 (1) = 1);
pragma Assert (A1 (1) = 10);
pragma Assert (A2 (1) = 1);
pragma Assert (A2 (1) = 2);
end Arrays_Declaration_Failure1;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[precondition_instance.1] file <internal> memcpy src/dst overlap: SUCCESS
[precondition_instance.2] file <internal> memcpy source region readable: SUCCESS
[precondition_instance.3] file <internal> memcpy destination region writeable: SUCCESS
[arrays_declaration_failure1.assertion.1] line 7 Ada Check assertion: SUCCESS
[arrays_declaration_failure1.assertion.2] line 8 assertion A1 (1) = 1: SUCCESS
[arrays_declaration_failure1.assertion.3] line 9 assertion A1 (1) = 10: FAILURE
[arrays_declaration_failure1.assertion.4] line 10 assertion A2 (1) = 1: SUCCESS
[arrays_declaration_failure1.assertion.5] line 11 assertion A2 (1) = 2: FAILURE
VERIFICATION FAILED
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-- see also test "arrays_multidimensional_declaration_failure2"
procedure Arrays_Declaration_Failure2 is
-- ERROR, "GNAT BUG DETECTED" "GNU Ada (ada2goto) Assert_Failure sinfo.adb:2232"
A1 : array (Integer range 1..3) of Integer;
begin
null;
A1 (1) := 10;
pragma Assert (A1 (1) = 10);
pragma Assert (A1 (1) = 20);
end Arrays_Declaration_Failure2;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[arrays_declaration_failure2.assertion.1] line 5 Ada Check assertion: SUCCESS
[arrays_declaration_failure2.assertion.2] line 6 assertion A1 (1) = 10: SUCCESS
[arrays_declaration_failure2.assertion.3] line 7 assertion A1 (1) = 20: FAILURE
VERIFICATION FAILED
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ALL XFAIL gnat2goto fails with "GNU Ada (ada2goto) Constraint_Error Symbol_Table_Info.Symbol_Maps.Constant_Reference: key not in map"
ALL XFAIL GNU Ada (ada2goto) Assert_Failure failed postcondition from arrays.ads
23 changes: 23 additions & 0 deletions testsuite/gnat2goto/tests/function_pointer/test.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
Standard_Output from gnat2goto test:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on with these two tests? This looks like the tests are now producing missing feature reports which they were not before.... Were this test and procedure_pointer both passing before this change?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s basically just Itypes that we never supported, but we just “happened” to pass these tests without missing feature reports or crashes because we don’t actually use these types anywhere in the resulting goto program.

I.e. as a side effect of some of the changes we’ve made in this PR some things that didn’t work before now visibly don’t work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. There's recently been some debate on #327 about whether we should or should not add "missing feature" reports to expected outputs - I'm not sure we came to a conclusion. In this case, it's probably better to accept it in the expected output and keep the test passing, rather than turn a passing test into an xfail.

----------At: Do_Itype_Definition----------
----------Unknown Ekind----------
N_Defining_Identifier "T6b" (Entity_Id=2491)
Parent = <empty>
Sloc = 8480 test.adb:13:4
Chars = "T6b" (Name_Id=300001463)
Next_Entity = N_Defining_Identifier "assert_compare" (Entity_Id=2476)
Scope = N_Defining_Identifier "test" (Entity_Id=2245)
Ekind = E_Access_Subtype
Etype = N_Defining_Identifier "comparator" (Entity_Id=2304)
Associated_Node_For_Itype = N_Procedure_Specification (Node_Id=2473)
Esize = 64 (Uint = 600032832)
RM_Size = 64 (Uint = 600032832)
Alignment = 4 (Uint = 600032772)
Directly_Designated_Type = N_Defining_Identifier "T3b" (Entity_Id=2451)
Can_Never_Be_Null = True
Has_Qualified_Name = True
Is_Frozen = True
Is_Internal = True
Is_Itype = True
Size_Known_At_Compile_Time = True

[assert_compare.assertion.1] line 15 assertion Func.all(5): FAILURE
VERIFICATION FAILED
23 changes: 23 additions & 0 deletions testsuite/gnat2goto/tests/procedure_pointer/test.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
Standard_Output from gnat2goto test:
----------At: Do_Itype_Definition----------
----------Unknown Ekind----------
N_Defining_Identifier "T4b" (Entity_Id=2491)
Parent = <empty>
Sloc = 8525 test.adb:14:4
Chars = "T4b" (Name_Id=300001462)
Next_Entity = N_Defining_Identifier "assert_modify" (Entity_Id=2476)
Scope = N_Defining_Identifier "test" (Entity_Id=2245)
Ekind = E_Access_Subtype
Etype = N_Defining_Identifier "modifier" (Entity_Id=2315)
Associated_Node_For_Itype = N_Procedure_Specification (Node_Id=2473)
Esize = 64 (Uint = 600032832)
RM_Size = 64 (Uint = 600032832)
Alignment = 4 (Uint = 600032772)
Directly_Designated_Type = N_Defining_Identifier "T1b" (Entity_Id=2451)
Can_Never_Be_Null = True
Has_Qualified_Name = True
Is_Frozen = True
Is_Internal = True
Is_Itype = True
Size_Known_At_Compile_Time = True

[assert_modify.assertion.1] line 17 assertion Global_Number = 5: FAILURE
[increment_by.assertion.1] line 5 Ada Check assertion: SUCCESS
VERIFICATION FAILED