OSDN Git Service

* env.c [__alpha__ && __osf__] (AES_SOURCE): Define.
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_warn.ads
index 0c5d759..4ab97be 100644 (file)
@@ -6,23 +6,20 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                            $Revision: 1.3 $
---                                                                          --
---          Copyright (C) 1999-2000 Free Software Foundation, Inc.          --
+--          Copyright (C) 1999-2009, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
+-- http://www.gnu.org/licenses for a complete copy of the license.          --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
--- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
 --  about uses of uninitialized variables and unused with's. It also has
 --  some unrelated routines related to the generation of warnings.
 
+with Alloc; use Alloc;
+with Table;
 with Types; use Types;
 
 package Sem_Warn is
 
+   ------------------------
+   -- Warnings Off Table --
+   ------------------------
+
+   type Warnings_Off_Entry is record
+      N : Node_Id;
+      --  A pragma Warnings (Off, ent) node
+
+      E : Entity_Id;
+      --  The entity involved
+   end record;
+
+   --  An entry is made in the following table for any valid Pragma Warnings
+   --  (Off, entity) encountered while Opt.Warn_On_Warnings_Off is True. It
+   --  is used to generate warnings on any of these pragmas that turn out not
+   --  to be needed, or that could be replaced by Unmodified/Unreferenced.
+
+   package Warnings_Off_Pragmas is new Table.Table (
+     Table_Component_Type => Warnings_Off_Entry,
+     Table_Index_Type     => Int,
+     Table_Low_Bound      => 0,
+     Table_Initial        => Alloc.Warnings_Off_Pragmas_Initial,
+     Table_Increment      => Alloc.Warnings_Off_Pragmas_Increment,
+     Table_Name           => "Name_Warnings_Off_Pragmas");
+
+   --------------------
+   -- Initialization --
+   --------------------
+
+   procedure Initialize;
+   --  Initialize this package for new compilation
+
+   function Set_Warning_Switch (C : Character) return Boolean;
+   --  This function sets the warning switch or switches corresponding to the
+   --  given character. It is used to process a -gnatw switch on the command
+   --  line, or a character in a string literal in pragma Warnings. Returns
+   --  True for valid warning character C, False for invalid character.
+
+   function Set_Dot_Warning_Switch (C : Character) return Boolean;
+   --  This function sets the warning switch or switches corresponding to the
+   --  given character preceded by a dot. Used to process a -gnatw. switch on
+   --  the command line or .C in a string literal in pragma Warnings. Returns
+   --  True for valid warning character C, False for invalid character.
+
+   procedure Set_GNAT_Mode_Warnings;
+   --  This is called in -gnatg mode to set the warnings for gnat mode. It is
+   --  also used to set the proper warning statuses for -gnatw.g.
+
    ------------------------------------------
    -- Routines to Handle Unused References --
    ------------------------------------------
@@ -87,54 +134,54 @@ package Sem_Warn is
    --  using the flags set by the initial call where appropriate to specialize
    --  the text of the warning messages.
 
-   ----------------------------------------
-   -- Routines to Deal with Conditionals --
-   ----------------------------------------
-
-   --  These routines provide the necessary interfacing information to
-   --  correctly handle references in conditional structures (if/then/end-if,
-   --  or case/when/end-case). The issue here is that if a variable is only
-   --  set in some but not all branches of a conditional, then it is not
-   --  considered as being set by the conditional as a whole.
-
-   procedure Start_Unit;
-   --  Mark start of new unit to be analyzed, deals with fact that a call to
-   --  Rtsfind may cause new unit to be analyzed in middle of conditional.
-
-   procedure End_Unit;
-   --  Mark end of unit corresponding to previous call to Start_Unit
-
-   procedure Start_Conditional (If_Stmt : Boolean);
-   --  Mark start of a new conditional structure (an if-elsif-else-endif
-   --  or a case-when-end-case structure). If_Stmt is True for the IF
-   --  statement case, and False for the CASE statement case.
-
-   procedure Start_Branch (Loc : Source_Ptr);
-   --  Start processing of one branch of conditional previously marked by
-   --  a call to Start_Conditional (i.e. start of then/elsif/else statements
-   --  or set of statements after a when condition). The Loc value is the
-   --  source pointer to be used in warning messages concerning variables
-   --  not properly initialized in this branch. A branch is terminated by
-   --  either another Start_Branch or End_Conditional call.
-
-   procedure End_Conditional;
-   --  Terminate conditional started by previous Start_Conditional statement.
-
    ---------------------
    -- Output Routines --
    ---------------------
 
+   procedure Output_Non_Modified_In_Out_Warnings;
+   --  Warnings about IN OUT parameters that could be IN are collected till
+   --  the end of the compilation process (see body of this routine for a
+   --  discussion of why this is done). This procedure outputs the warnings.
+   --  Note: this should be called before Output_Unreferenced_Messages, since
+   --  if we have an IN OUT warning, that's the one we want to see!
+
+   procedure Output_Obsolescent_Entity_Warnings (N : Node_Id; E : Entity_Id);
+   --  N is a reference to obsolescent entity E, for which appropriate warning
+   --  messages are to be generated (caller has already checked that warnings
+   --  are active and appropriate for this entity).
+
    procedure Output_Unreferenced_Messages;
    --  Warnings about unreferenced entities are collected till the end of
    --  the compilation process (see Check_Unset_Reference for further
    --  details). This procedure outputs waiting warnings, if any.
 
+   procedure Output_Unused_Warnings_Off_Warnings;
+   --  Warnings about pragma Warnings (Off, ent) statements that are unused,
+   --  or could be replaced by Unmodified/Unreferenced pragmas, are collected
+   --  till the end of the compilation process. This procedure outputs waiting
+   --  warnings if any.
+
    ----------------------------
    -- Other Warning Routines --
    ----------------------------
 
+   procedure Check_Code_Statement (N : Node_Id);
+   --  Perform warning checks on a code statement node
+
+   procedure Check_Infinite_Loop_Warning (Loop_Statement : Node_Id);
+   --  N is the node for a loop statement. This procedure checks if a warning
+   --  should be given for a possible infinite loop, and if so issues it.
+
+   procedure Check_Low_Bound_Tested (Expr : Node_Id);
+   --  Expr is the node for a comparison operation. This procedure checks if
+   --  the comparison is a source comparison of P'First with some other value
+   --  and if so, sets the Low_Bound_Tested flag on entity P to suppress
+   --  warnings about improper low bound assumptions (we assume that if the
+   --  code has a test that explicitly checks P'First, then it is not operating
+   --  in blind assumption mode).
+
    procedure Warn_On_Known_Condition (C : Node_Id);
-   --  C is a node for a boolean expression resluting from a relational
+   --  C is a node for a boolean expression resulting from a relational
    --  or membership operation. If the expression has a compile time known
    --  value, then a warning is output if all the following conditions hold:
    --
@@ -158,4 +205,43 @@ package Sem_Warn is
    --  If all these conditions are met, the warning is issued noting that
    --  the result of the test is always false or always true as appropriate.
 
+   function Warn_On_Modified_As_Out_Parameter (E : Entity_Id) return Boolean;
+   --  Returns True if we should activate warnings for entity E being modified
+   --  as an out parameter. True if either Warn_On_Modified_Unread is set for
+   --  an only OUT parameter, or if Warn_On_All_Unread_Out_Parameters is set.
+
+   procedure Warn_On_Suspicious_Index (Name : Entity_Id; X : Node_Id);
+   --  This is called after resolving an indexed component or a slice. Name
+   --  is the entity for the name of the indexed array, and X is the subscript
+   --  for the indexed component case, or one of the bounds in the slice case.
+   --  If Name is an unconstrained parameter of a standard string type, and
+   --  the index is of the form of a literal or Name'Length [- literal], then
+   --  a warning is generated that the subscripting operation is possibly
+   --  incorrectly assuming a lower bound of 1.
+
+   procedure Warn_On_Unassigned_Out_Parameter
+     (Return_Node : Node_Id;
+      Scope_Id    : Entity_Id);
+   --  Called when processing a return statement given by Return_Node. Scope_Id
+   --  is the Entity_Id for the procedure in which the return statement lives.
+   --  A check is made for the case of a procedure with out parameters that
+   --  have not yet been assigned, and appropriate warnings are given.
+
+   procedure Warn_On_Useless_Assignment
+     (Ent : Entity_Id;
+      N   : Node_Id := Empty);
+   --  Called to check if we have a case of a useless assignment to the given
+   --  entity Ent, as indicated by a non-empty Last_Assignment field. This call
+   --  should only be made if at least one of the flags Warn_On_Modified_Unread
+   --  or Warn_On_All_Unread_Out_Parameters is True, and if Ent is in the
+   --  extended main source unit. N is Empty for the end of block call
+   --  (warning message says value unreferenced), or the it is the node for
+   --  an overwriting assignment (warning message points to this assignment).
+
+   procedure Warn_On_Useless_Assignments (E : Entity_Id);
+   pragma Inline (Warn_On_Useless_Assignments);
+   --  Called at the end of a block or subprogram. Scans the entities of the
+   --  block or subprogram to see if there are any variables for which useless
+   --  assignments were made (assignments whose values were never read).
+
 end Sem_Warn;