diff mbox

[Ada] Always require an elaboration counter when preserving control flow

Message ID 20160419131952.GA15431@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet April 19, 2016, 1:19 p.m. UTC
When control flow preservation is requested, we want to be explicit
about the units elaboration order in a partition, and we need to have
the elaboration counter available for that. This patch ensures we do,
even in circumstances where we are otherwise allowed to omit the
elaboration counter, e.g. under control of a No_Elaboration_Code pragma.

Compiling the code below:

   pragma Restrictions (No_Elaboration_Code);
   package Noelab is
     type Myint is new integer;
   end;

With -fpreserve-control-flow is expected to produce a "noelab_E"
counter, not there in absence of the option.

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

2016-04-19  Olivier Hainque  <hainque@adacore.com>

	* sem_util.adb (Build_Elaboration_Entity): Always request an
	elab counter when preserving control-flow.
diff mbox

Patch

Index: sem_util.adb
===================================================================
--- sem_util.adb	(revision 235200)
+++ sem_util.adb	(working copy)
@@ -1662,10 +1662,18 @@ 
       elsif ASIS_Mode then
          return;
 
-      --  See if we need elaboration entity. We always need it for the dynamic
-      --  elaboration model, since it is needed to properly generate the PE
-      --  exception for access before elaboration.
+      --  See if we need elaboration entity.
 
+      --  We always need an elaboration entity when preserving control-flow, as
+      --  we want to remain explicit about the units elaboration order.
+
+      elsif Opt.Suppress_Control_Flow_Optimizations then
+         null;
+
+      --  We always need an elaboration entity for the dynamic elaboration
+      --  model, since it is needed to properly generate the PE exception for
+      --  access before elaboration.
+
       elsif Dynamic_Elaboration_Checks then
          null;