From e2819941fc6eb15c3955d75e45f30dedb3713389 Mon Sep 17 00:00:00 2001 From: Hristian Kirtchev Date: Tue, 11 Dec 2018 11:10:42 +0000 Subject: [Ada] Crash on ignored Ghost expression function This patch updates freezing to ensure that freeze nodes are inserted into the tree when the entity being frozen is non-Ghost, and the context is an ignored Ghost spec expression. 2018-12-11 Hristian Kirtchev gcc/ada/ * exp_util.adb (Insert_Action): Add new formal parameter Spec_Expr_OK. (Insert_Actions): Add new formal parameter Spec_Expr_OK. Update all calls to Insert_Actions where relevant. Honour an insertion from a spec expression context when requested by the caller. * exp_util.ads (Insert_Action): Add new formal parameter Spec_Expr_OK. (Insert_Actions): Add new formal parameter Spec_Expr_OK. * freeze.adb (Add_To_Result): Force the insertion of the freeze node even when the context is a spec expression. gcc/testsuite/ * gnat.dg/ghost2.adb, gnat.dg/ghost2.ads: New testcase. From-SVN: r266996 --- gcc/ada/exp_util.ads | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'gcc/ada/exp_util.ads') diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index ab48b74..97eccdd 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -89,39 +89,54 @@ package Exp_Util is -- calls, and this guarantee is preserved for the special cases above. procedure Insert_Action - (Assoc_Node : Node_Id; - Ins_Action : Node_Id); + (Assoc_Node : Node_Id; + Ins_Action : Node_Id; + Spec_Expr_OK : Boolean := False); -- Insert the action Ins_Action at the appropriate point as described -- above. The action is analyzed using the default checks after it is -- inserted. Assoc_Node is the node with which the action is associated. + -- When flag Spec_Expr_OK is set, insertions triggered in the context of + -- spec expressions are honoured, even though they contradict "Handling + -- of Default and Per-Object Expressions". procedure Insert_Action - (Assoc_Node : Node_Id; - Ins_Action : Node_Id; - Suppress : Check_Id); + (Assoc_Node : Node_Id; + Ins_Action : Node_Id; + Suppress : Check_Id; + Spec_Expr_OK : Boolean := False); -- Insert the action Ins_Action at the appropriate point as described -- above. The action is analyzed using the default checks as modified -- by the given Suppress argument after it is inserted. Assoc_Node is - -- the node with which the action is associated. + -- the node with which the action is associated. When flag Spec_Expr_OK + -- is set, insertions triggered in the context of spec expressions are + -- honoured, even though they contradict "Handling of Default and Per- + -- Object Expressions". procedure Insert_Actions - (Assoc_Node : Node_Id; - Ins_Actions : List_Id); + (Assoc_Node : Node_Id; + Ins_Actions : List_Id; + Spec_Expr_OK : Boolean := False); -- Insert the list of action Ins_Actions at the appropriate point as -- described above. The actions are analyzed using the default checks -- after they are inserted. Assoc_Node is the node with which the actions -- are associated. Ins_Actions may be No_List, in which case the call has - -- no effect. + -- no effect. When flag Spec_Expr_OK is set, insertions triggered in the + -- context of spec expressions are honoured, even though they contradict + -- "Handling of Default and Per-Object Expressions". procedure Insert_Actions - (Assoc_Node : Node_Id; - Ins_Actions : List_Id; - Suppress : Check_Id); + (Assoc_Node : Node_Id; + Ins_Actions : List_Id; + Suppress : Check_Id; + Spec_Expr_OK : Boolean := False); -- Insert the list of action Ins_Actions at the appropriate point as -- described above. The actions are analyzed using the default checks -- as modified by the given Suppress argument after they are inserted. - -- Assoc_Node is the node with which the actions are associated. + -- Assoc_Node is the node with which the actions are associated. List -- Ins_Actions may be No_List, in which case the call has no effect. + -- When flag Spec_Expr_OK is set, insertions triggered in the context of + -- spec expressions are honoured, even though they contradict "Handling + -- of Default and Per-Object Expressions". procedure Insert_Action_After (Assoc_Node : Node_Id; -- cgit v1.1