Patchwork [Ada] Support for coverage analysis of ACCEPT alternatives in SELECT statement

login
register
mail settings
Submitter Arnaud Charlet
Date July 23, 2012, 8:13 a.m.
Message ID <20120723081331.GA5913@adacore.com>
Download mbox | patch
Permalink /patch/172571/
State New
Headers show

Comments

Arnaud Charlet - July 23, 2012, 8:13 a.m.
This change ensures that the NULL statement generated for coverage analysis
purposes in an otherwise empty ACCEPT alternative is not eliminated by GIGI
or the code generator by setting its Comes_From_Source flag.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-07-23  Thomas Quinot  <quinot@adacore.com>

	* exp_ch9.adb (Ensure_Statement_Present): Mark generated NULL
	statement as Comes_From_Source so that GIGI does not eliminate it.

Patch

Index: exp_ch9.adb
===================================================================
--- exp_ch9.adb	(revision 189768)
+++ exp_ch9.adb	(working copy)
@@ -5484,11 +5484,19 @@ 
    ------------------------------
 
    procedure Ensure_Statement_Present (Loc : Source_Ptr; Alt : Node_Id) is
+      Stmt : Node_Id;
    begin
       if Opt.Suppress_Control_Flow_Optimizations
         and then Is_Empty_List (Statements (Alt))
       then
-         Set_Statements (Alt, New_List (Make_Null_Statement (Loc)));
+         Stmt := Make_Null_Statement (Loc);
+
+         --  Mark NULL statement as coming from source so that it is not
+         --  eliminated by GIGI.
+
+         Set_Comes_From_Source (Stmt, True);
+
+         Set_Statements (Alt, New_List (Stmt));
       end if;
    end Ensure_Statement_Present;