* 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 <charlet@adacore.com>
* exp_disp.adb: Update comments.
2014-01-31 Yannick Moy <moy@adacore.com>
* sem_ch12.adb (Analyze_Generic_Subprogram_Declaration,
Save_Global_References): Guard access to expression in aspect.
2014-01-31 Yannick Moy <moy@adacore.com>
* 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 <moy@adacore.com>
* sem_ch8.adb (Analyze_Subprogram_Renaming): Set SPARK_Mode on renaming
entity.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207352
138bc75d-0d04-0410-961f-
82ee72b054a4
+2014-01-31 Robert Dewar <dewar@adacore.com>
+
+ * 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 <charlet@adacore.com>
+
+ * exp_disp.adb: Update comments.
+
+2014-01-31 Yannick Moy <moy@adacore.com>
+
+ * sem_ch12.adb (Analyze_Generic_Subprogram_Declaration,
+ Save_Global_References): Guard access to expression in aspect.
+
+2014-01-31 Yannick Moy <moy@adacore.com>
+
+ * 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 <moy@adacore.com>
+
+ * sem_ch8.adb (Analyze_Subprogram_Renaming): Set SPARK_Mode on renaming
+ entity.
+
2014-01-31 Robert Dewar <dewar@adacore.com>
* exp_ch9.adb, s-tassta.adb, s-tposen.adb, s-tposen.ads: Minor
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);
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, ..)
(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;
-- 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 =>
@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)}
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.}
-- 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;
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;
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;
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;
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
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
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;
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
-- 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