GNAT has several switches that affect the elaboration model and consequently the elaboration order chosen by the binder.
Dynamic elaboration checking mode enabled
When this switch is in effect, GNAT activates the dynamic elaboration model.
Turn on info messages on generated Elaborate[_All] pragmas
When this switch is in effect, GNAT will emit the following supplementary information depending on the elaboration model in effect.
GNAT will indicate missing
Elaborate_All pragmas for
all library-level scenarios within the partition.
GNAT will indicate all scenarios executed during elaboration. In addition,
it will provide detailed traceback when an implicit
Elaborate_All pragma is generated.
GNAT will indicate how an elaboration requirement is met by the context of
a unit. This diagnostic requires compiler switch
1. with Server; pragma Elaborate_All (Server); 2. package Client with SPARK_Mode is 3. Val : constant Integer := Server.Func; | >>> info: call to "Func" during elaboration in SPARK >>> info: "Elaborate_All" requirement for unit "Server" met by pragma at line 1 4. end Client;
Legacy elaboration checking mode enabled
When this switch is in effect, GNAT will utilize the pre-18.x elaboration model.
Relaxed elaboration checking mode enabled
When this switch is in effect, GNAT will not process certain scenarios, resulting in a more permissive elaboration model. Note that this may eliminate some diagnostics and run-time checks.
Turn on warnings for suspicious Subp’Access
When this switch is in effect, GNAT will treat
'Access of an entry,
operator, or subprogram as a potential call to the target and issue warnings:
1. package body Attribute_Call is 2. function Func return Integer; 3. type Func_Ptr is access function return Integer; 4. 5. Ptr : constant Func_Ptr := Func'Access; | >>> warning: "Access" attribute of "Func" before body seen >>> warning: possible Program_Error on later references >>> warning: body of unit "Attribute_Call" elaborated >>> warning: "Access" of "Func" taken at line 5 6. 7. function Func return Integer is 8. begin 9. ... 10. end Func; 11. end Attribute_Call;
In the example above, the elaboration of declaration
Ptr is assigned
Func'Access before the body of
Func has been elaborated.
Turn on warnings for elaboration problems
When this switch is in effect, GNAT emits diagnostics in the form of warnings concerning various elaboration problems. The warnings are enabled by default. The switch is provided in case all warnings are suppressed, but elaboration warnings are still desired.
Turn off warnings for elaboration problems
When this switch is in effect, GNAT no longer emits any diagnostics in the
form of warnings. Selective suppression of elaboration problems is possible
pragma Warnings (Off).
1. package body Selective_Suppression is 2. function ABE return Integer; 3. 4. Val_1 : constant Integer := ABE; | >>> warning: cannot call "ABE" before body seen >>> warning: Program_Error will be raised at run time 5. 6. pragma Warnings (Off); 7. Val_2 : constant Integer := ABE; 8. pragma Warnings (On); 9. 10. function ABE return Integer is 11. begin 12. ... 13. end ABE; 14. end Selective_Suppression;
Note that suppressing elaboration warnings does not eliminate run-time checks. The example above will still fail at run time with an ABE.