@@ -751,6 +751,7 @@
Identifier_Character_Set := 'n';
System_Extend_Unit := Empty;
Warning_Mode := Treat_As_Error;
+ Style_Check_Main := True;
-- Set Ada 2012 mode explicitly. We don't want to rely on the
-- implicit setting here, since for example, we want
@@ -1173,6 +1174,7 @@
when 'y' =>
Ptr := Ptr + 1;
+ Style_Check_Main := True;
if Ptr > Max then
@@ -2457,14 +2457,6 @@
- -- We reset ordinary style checking during the analysis of a with'ed
- -- unit, but we do NOT reset GNAT special analysis mode (the latter
- -- definitely *does* apply to with'ed units).
- if not GNAT_Mode then
- Style_Check := False;
- end if;
-- If the library unit is a predefined unit, and we are in high
-- integrity mode, then temporarily reset Configurable_Run_Time_Mode
-- for the analysis of the with'ed unit. This mode does not prevent
@@ -1311,6 +1311,7 @@
S_In_Spec_Expr : constant Boolean := In_Spec_Expression;
S_Inside_A_Generic : constant Boolean := Inside_A_Generic;
S_Outer_Gen_Scope : constant Entity_Id := Outer_Generic_Scope;
+ S_Style_Check : constant Boolean := Style_Check;
Generic_Main : constant Boolean :=
Nkind (Unit (Cunit (Main_Unit)))
@@ -1318,6 +1319,10 @@
-- If the main unit is generic, every compiled unit, including its
-- context, is compiled with expansion disabled.
+ Ext_Main_Source_Unit : constant Boolean :=
+ In_Extended_Main_Source_Unit (Comp_Unit);
+ -- Determine if unit is in extended main source unit
Save_Config_Switches : Config_Switches_Type;
-- Variable used to save values of config switches while we analyze the
-- new unit, to be restored on exit for proper recursive behavior.
@@ -1386,9 +1391,6 @@
-- Sequential_IO) as this would prevent pragma Extend_System from being
-- taken into account, for example when Text_IO is renaming DEC.Text_IO.
- -- Cleaner might be to do the kludge at the point of excluding the
- -- pragma (do not exclude for renamings ???)
(Unit_File_Name (Current_Sem_Unit), Renamings_Included => False)
@@ -1423,12 +1425,28 @@
-- For unit in main extended unit, we reset the configuration values
-- for the non-partition-wide restrictions. For other units reset them.
- if In_Extended_Main_Source_Unit (Comp_Unit) then
+ if Ext_Main_Source_Unit then
+ -- Turn off style checks for unit that is not in the extended main
+ -- source unit. This improves processing efficiency for such units
+ -- (for which we don't want style checks anyway, and where they will
+ -- get suppressed), and is definitely needed to stop some style checks
+ -- from invading the run-time units (e.g. overriding checks).
+ if not Ext_Main_Source_Unit then
+ Style_Check := False;
+ -- If this is part of the extended main source unit, set style check
+ -- mode to match the style check mode of the main source unit itself.
+ Style_Check := Style_Check_Main;
+ end if;
-- Only do analysis of unit that has not already been analyzed
if not Analyzed (Comp_Unit) then
@@ -1482,6 +1500,7 @@
In_Spec_Expression := S_In_Spec_Expr;
Inside_A_Generic := S_Inside_A_Generic;
Outer_Generic_Scope := S_Outer_Gen_Scope;
+ Style_Check := S_Style_Check;
@@ -1267,8 +1267,16 @@
-- Set True to perform style checks. Activates checks carried out in
-- package Style (see body of this package for details of checks). This
- -- flag is set True by either the -gnatg or -gnaty switches.
+ -- flag is set True by use of either the -gnatg or -gnaty switches, or
+ -- by the Style_Check pragma.
+ Style_Check_Main : Boolean := False;
+ -- GNAT
+ -- Set True if Style_Check was set for the main unit. This is used to
+ -- renable style checks for units in the mail extended source that get
+ -- with'ed indirectly. It is set on by use of either the -gnatg or -gnaty
+ -- switches, but not by use of the Style_Checks pragma.
Suppress_All_Inlining : Boolean := False;
-- Set by -fno-inline. Suppresses all inlining, both front end and back end