Next: Common Elaboration-model Traits, Previous: Controlling the Elaboration Order in Ada, Up: Elaboration Order Handling in GNAT [Contents][Index]
In addition to Ada semantics and rules synthesized from them, GNAT offers three elaboration models to aid the programmer with specifying the correct elaboration order and to diagnose elaboration problems.
This is the most permissive of the three elaboration models. When the
dynamic model is in effect, GNAT assumes that all code within all units in
a partition is elaboration code. GNAT performs very few diagnostics and
generates run-time checks to verify the elaboration order of a program. This
behavior is identical to that specified by the Ada Reference Manual. The
dynamic model is enabled with compiler switch -gnatE
.
This is the middle ground of the three models. When the static model is in
effect, GNAT performs extensive diagnostics on a unit-by-unit basis for all
scenarios that elaborate or execute internal targets. GNAT also generates
run-time checks for all external targets and for all scenarios that may
exhibit ABE problems. Finally, GNAT installs implicit Elaborate
and
Elaborate_All
pragmas for server units based on the dependencies of
client units. The static model is the default model in GNAT.
This is the most conservative of the three models and enforces the SPARK rules of elaboration as defined in the SPARK Reference Manual, section 7.7. The SPARK model is in effect only when a scenario and a target reside in a region subject to SPARK_Mode On, otherwise the dynamic or static model is in effect.
In addition to the three elaboration models outlined above, GNAT provides the
elaboration model of pre-18.x versions referred to as legacy elaboration model. The legacy elaboration model is enabled with compiler switch
-gnatH
.
The dynamic, legacy, and static models can be relaxed using compiler switch
-gnatJ
, making them more permissive. Note that in this mode, GNAT
may not diagnose certain elaboration issues or install run-time checks.