This patch turns off style checking in instances.
The following should compile quietly with -gnatyO:
gcc -c -gnatyO -gnatl p.ads
with Ada.Strings.Bounded;
package P is new
Ada.Strings.Bounded.Generic_Bounded_Length (100);
Tested on x86_64-pc-linux-gnu, committed on trunk
2011-08-02 Bob Duff <[email protected]>
* sem_ch12.adb (Analyze_Package_Instantiation,
Analyze_Subprogram_Instantiation): Turn off style checking while
analyzing an instance. Whatever style checks that apply to the generic
unit should apply, so it makes no sense to apply them in an instance.
This was causing trouble when compiling an instance of a runtime
unit that violates the -gnatyO switch.
* stylesw.adb (Set_Style_Check_Options): "when 'O' =>" was missing from
one of the two case statements, causing spurious errors.
Index: sem_ch12.adb
===================================================================
--- sem_ch12.adb (revision 177110)
+++ sem_ch12.adb (working copy)
@@ -2975,6 +2975,8 @@
return False;
end Might_Inline_Subp;
+ Save_Style_Check : constant Boolean := Style_Check;
+
-- Start of processing for Analyze_Package_Instantiation
begin
@@ -2987,6 +2989,12 @@
Instantiation_Node := N;
+ -- Turn off style checking in instances. If the check is enabled on the
+ -- generic unit, a warning in an instance would just be noise. If not
+ -- enabled on the generic, then a warning in an instance is just wrong.
+
+ Style_Check := False;
+
-- Case of instantiation of a generic package
if Nkind (N) = N_Package_Instantiation then
@@ -3571,6 +3579,8 @@
Set_Defining_Identifier (N, Act_Decl_Id);
end if;
+ Style_Check := Save_Style_Check;
+
<<Leave>>
if Has_Aspects (N) then
Analyze_Aspect_Specifications (N, Act_Decl_Id);
@@ -3585,6 +3595,8 @@
if Env_Installed then
Restore_Env;
end if;
+
+ Style_Check := Save_Style_Check;
end Analyze_Package_Instantiation;
--------------------------
@@ -4104,6 +4116,8 @@
end if;
end Analyze_Instance_And_Renamings;
+ Save_Style_Check : constant Boolean := Style_Check;
+
-- Start of processing for Analyze_Subprogram_Instantiation
begin
@@ -4117,6 +4131,13 @@
-- Make node global for error reporting
Instantiation_Node := N;
+
+ -- Turn off style checking in instances. If the check is enabled on the
+ -- generic unit, a warning in an instance would just be noise. If not
+ -- enabled on the generic, then a warning in an instance is just wrong.
+
+ Style_Check := False;
+
Preanalyze_Actuals (N);
Init_Env;
@@ -4352,6 +4373,8 @@
Generic_Renamings_HTable.Reset;
end if;
+ Style_Check := Save_Style_Check;
+
<<Leave>>
if Has_Aspects (N) then
Analyze_Aspect_Specifications (N, Act_Decl_Id);
@@ -4366,6 +4389,8 @@
if Env_Installed then
Restore_Env;
end if;
+
+ Style_Check := Save_Style_Check;
end Analyze_Subprogram_Instantiation;
-------------------------
Index: stylesw.adb
===================================================================
--- stylesw.adb (revision 176998)
+++ stylesw.adb (working copy)
@@ -530,6 +530,9 @@
when 'o' =>
Style_Check_Order_Subprograms := False;
+ when 'O' =>
+ Style_Check_Missing_Overriding := False;
+
when 'p' =>
Style_Check_Pragma_Casing := False;