From: Arnaud Charlet Date: Fri, 31 Jan 2014 15:46:40 +0000 (+0100) Subject: [multiple changes] X-Git-Tag: releases/gcc-4.9.0~1185 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=74c101097fb411445f543989120d83f53de5e4b0;p=thirdparty%2Fgcc.git [multiple changes] 2014-01-31 Robert Dewar * erroutc.adb (Validate_Specific_Warnings): Warnings are controlled -gnatw.W. * gnat_ugn.texi: Document new warnings controlled by -gnatw.w. * opt.ads (Warn_On_Warnings_Off): Now controls more cases. 2014-01-31 Arnaud Charlet * exp_disp.adb: Update comments. 2014-01-31 Yannick Moy * sem_ch12.adb (Analyze_Generic_Subprogram_Declaration, Save_Global_References): Guard access to expression in aspect. 2014-01-31 Yannick Moy * sem_prag.adb (Analyze_Pragma/Pragma_SPARK_Mode): Issue an error when the pragma is applied to a generic unit, a generic declaration, or inside a generic. 2014-01-31 Yannick Moy * sem_ch8.adb (Analyze_Subprogram_Renaming): Set SPARK_Mode on renaming entity. From-SVN: r207352 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index aa976653f2a3..12f5d5a70bf4 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,30 @@ +2014-01-31 Robert Dewar + + * erroutc.adb (Validate_Specific_Warnings): Warnings are + controlled -gnatw.W. + * gnat_ugn.texi: Document new warnings controlled by -gnatw.w. + * opt.ads (Warn_On_Warnings_Off): Now controls more cases. + +2014-01-31 Arnaud Charlet + + * exp_disp.adb: Update comments. + +2014-01-31 Yannick Moy + + * sem_ch12.adb (Analyze_Generic_Subprogram_Declaration, + Save_Global_References): Guard access to expression in aspect. + +2014-01-31 Yannick Moy + + * sem_prag.adb (Analyze_Pragma/Pragma_SPARK_Mode): + Issue an error when the pragma is applied to a generic unit, + a generic declaration, or inside a generic. + +2014-01-31 Yannick Moy + + * sem_ch8.adb (Analyze_Subprogram_Renaming): Set SPARK_Mode on renaming + entity. + 2014-01-31 Robert Dewar * exp_ch9.adb, s-tassta.adb, s-tposen.adb, s-tposen.ads: Minor diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb index f70fc60d926c..3387623b8ff7 100644 --- a/gcc/ada/erroutc.adb +++ b/gcc/ada/erroutc.adb @@ -1300,6 +1300,10 @@ package body Erroutc is procedure Validate_Specific_Warnings (Eproc : Error_Msg_Proc) is begin + if not Warn_On_Warnings_Off then + return; + end if; + for J in Specific_Warnings.First .. Specific_Warnings.Last loop declare SWE : Specific_Warning_Entry renames Specific_Warnings.Table (J); @@ -1311,7 +1315,7 @@ package body Erroutc is if SWE.Open then Eproc.all - ("?pragma Warnings Off with no matching Warnings On", + ("?W?pragma Warnings Off with no matching Warnings On", SWE.Start); -- Warn for ineffective Warnings (Off, ..) @@ -1332,7 +1336,7 @@ package body Erroutc is (SWE.Msg'Length > 2 and then SWE.Msg (1 .. 2) = "-W") then Eproc.all - ("?no warning suppressed by this pragma", SWE.Start); + ("?W?no warning suppressed by this pragma", SWE.Start); end if; end if; end; diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index 33275d506d7d..dca778cc64f9 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -3526,8 +3526,9 @@ package body Exp_Disp is -- entry protected types (in s-tposen). However, it was removed -- by also testing for no No_Select_Statements restriction in -- Exp_Utils.Corresponding_Runtime_Package. This simplified the - -- implementation of s-tposen, which was initially created for - -- the Ravenscar profile. + -- implementation of s-tposen.adb and provided consistency between + -- all versions of System.Tasking.Protected_Objects.Single_Entry + -- (s-tposen*.adb). case Corresponding_Runtime_Package (Conc_Typ) is when System_Tasking_Protected_Objects_Entries => diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index c5632d784495..b6d05cdb7af4 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -5690,7 +5690,7 @@ as shown in the following example. @end smallexample @item -gnatw.w -@emph{Activate warnings on unnecessary Warnings Off pragmas} +@emph{Activate warnings on Warnings Off pragmas} @cindex @option{-gnatw.w} (@command{gcc}) @cindex Warnings Off control This switch activates warnings for use of @code{pragma Warnings (Off, entity)} @@ -5698,12 +5698,14 @@ where either the pragma is entirely useless (because it suppresses no warnings), or it could be replaced by @code{pragma Unreferenced} or @code{pragma Unmodified}. The default is that these warnings are not given. Note that this warning is not included in -gnatwa, it must be -activated explicitly. +activated explicitly. Also activates warnings for the case of +Warnings (Off, String), where either there is no matching +Warnings (On, String), or the Warnings (Off) did not suppress any warning. @item -gnatw.W @emph{Suppress warnings on unnecessary Warnings Off pragmas} @cindex @option{-gnatw.W} (@command{gcc}) -This switch suppresses warnings for use of @code{pragma Warnings (Off, entity)}. +This switch suppresses warnings for use of @code{pragma Warnings (Off, ...)}. @item -gnatwx @emph{Activate warnings on Export/Import pragmas.} diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index f5349f55b2d3..95f87e81629a 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -1729,7 +1729,10 @@ package Opt is -- GNAT -- Set to True to generate warnings for use of Pragma Warnings (Off, ent), -- where either the pragma is never used, or it could be replaced by a - -- pragma Unmodified or Unreferenced. Modified by use of -gnatw.w/.W. + -- pragma Unmodified or Unreferenced. Also generates warnings for pragma + -- Warning (Off, string) which either has no matching pragma Warning On, + -- or where no warning has been suppressed by the use of the pragma. + -- Modified by use of -gnatw.w/.W. type Warning_Mode_Type is (Suppress, Normal, Treat_As_Error); Warning_Mode : Warning_Mode_Type := Normal; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 4ddfdc56220a..78881a903347 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -3251,7 +3251,9 @@ package body Sem_Ch12 is begin Aspect := First (Aspect_Specifications (N)); while Present (Aspect) loop - if Get_Aspect_Id (Aspect) /= Aspect_Warnings then + if Get_Aspect_Id (Aspect) /= Aspect_Warnings + and then Present (Expression (Aspect)) + then Analyze (Expression (Aspect)); end if; @@ -3260,7 +3262,10 @@ package body Sem_Ch12 is Aspect := First (Aspect_Specifications (Original_Node (N))); while Present (Aspect) loop - Save_Global_References (Expression (Aspect)); + if Present (Expression (Aspect)) then + Save_Global_References (Expression (Aspect)); + end if; + Next (Aspect); end loop; end; @@ -13729,16 +13734,19 @@ package body Sem_Ch12 is end if; -- If a node has aspects, references within their expressions must - -- be saved separately, given that they are not directly in the - -- tree. + -- be saved separately, given they are not directly in the tree. if Has_Aspects (N) then declare Aspect : Node_Id; + begin Aspect := First (Aspect_Specifications (N)); while Present (Aspect) loop - Save_Global_References (Expression (Aspect)); + if Present (Expression (Aspect)) then + Save_Global_References (Expression (Aspect)); + end if; + Next (Aspect); end loop; end; diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 0868e01ab796..773929dcf3ab 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -2386,6 +2386,11 @@ package body Sem_Ch8 is Set_Is_Pure (New_S, Is_Pure (Current_Scope)); end if; + -- Set SPARK mode from current context + + Set_SPARK_Pragma (New_S, SPARK_Mode_Pragma); + Set_SPARK_Pragma_Inherited (New_S, True); + Rename_Spec := Find_Corresponding_Spec (N); -- Case of Renaming_As_Body diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index a3711c8353dd..6e29b8b5fcdf 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -19160,6 +19160,10 @@ package body Sem_Prag is Check_No_Identifiers; Check_At_Most_N_Arguments (1); + if Inside_A_Generic then + Error_Pragma ("incorrect placement of pragma% in a generic"); + end if; + -- Check the legality of the mode (no argument = ON) if Arg_Count = 1 then @@ -19192,6 +19196,15 @@ package body Sem_Prag is elsif Nkind (Context) = N_Compilation_Unit then Check_Valid_Configuration_Pragma; + if Nkind (Unit (Context)) in N_Generic_Declaration + or else (Present (Library_Unit (Context)) + and then Nkind (Unit (Library_Unit (Context))) in + N_Generic_Declaration) + then + Error_Pragma + ("incorrect placement of pragma% in a generic unit"); + end if; + SPARK_Mode_Pragma := N; SPARK_Mode := Mode_Id; @@ -19219,11 +19232,13 @@ package body Sem_Prag is elsif not Comes_From_Source (Stmt) then null; + elsif Nkind (Stmt) in N_Generic_Declaration then + Error_Pragma + ("incorrect placement of pragma% on a generic"); + -- The pragma applies to a package declaration - elsif Nkind_In (Stmt, N_Generic_Package_Declaration, - N_Package_Declaration) - then + elsif Nkind (Stmt) = N_Package_Declaration then Spec_Id := Defining_Entity (Stmt); Check_Library_Level_Entity (Spec_Id); Check_Pragma_Conformance @@ -19239,9 +19254,7 @@ package body Sem_Prag is -- The pragma applies to a subprogram declaration - elsif Nkind_In (Stmt, N_Generic_Subprogram_Declaration, - N_Subprogram_Declaration) - then + elsif Nkind (Stmt) = N_Subprogram_Declaration then Spec_Id := Defining_Entity (Stmt); Check_Library_Level_Entity (Spec_Id); Check_Pragma_Conformance