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  <hain...@adacore.com>

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

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;
 

Reply via email to