OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / erroutc.ads
index bde0574..6c077b0 100644 (file)
@@ -6,18 +6,17 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2011, 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,  51  Franklin  Street,  Fifth  Floor, --
--- Boston, MA 02110-1301, 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. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
@@ -37,10 +36,14 @@ package Erroutc is
    --  type, and is used by Add_Class to insert 'Class at the proper point
 
    Continuation : Boolean := False;
-   --  Indicates if current message is a continuation. Intialized from the
+   --  Indicates if current message is a continuation. Initialized from the
    --  Msg_Cont parameter in Error_Msg_Internal and then set True if a \
    --  insertion character is encountered.
 
+   Continuation_New_Line : Boolean := False;
+   --  Indicates if current message was a continuation line marked with \\ to
+   --  force a new line. Set True if \\ encountered.
+
    Flag_Source : Source_File_Index;
    --  Source file index for source file where error is being posted
 
@@ -49,6 +52,7 @@ package Erroutc is
 
    Is_Style_Msg : Boolean := False;
    --  Set True to indicate if the current message is a style message
+   --  (i.e. a message whose text starts with the characters "(style)").
 
    Is_Serious_Error : Boolean := False;
    --  Set by Set_Msg_Text to indicate if current message is serious error
@@ -78,9 +82,9 @@ package Erroutc is
 
    Max_Msg_Length : constant := 1024 + 2 * Int (Column_Number'Last);
    --  Maximum length of error message. The addition of 2 * Column_Number'Last
-   --  ensures that two insertion tokens of maximum length can be accomodated.
+   --  ensures that two insertion tokens of maximum length can be accommodated.
    --  The value of 1024 is an arbitrary value that should be more than long
-   --  enough to accomodate any reasonable message (and for that matter, some
+   --  enough to accommodate any reasonable message (and for that matter, some
    --  pretty unreasonable messages!)
 
    Msg_Buffer : String (1 .. Max_Msg_Length);
@@ -112,7 +116,7 @@ package Erroutc is
 
    No_Error_Msg : constant Error_Msg_Id := 0;
    --  A constant which is different from any value returned by Get_Error_Id.
-   --  Typically used by a client to indicate absense of a saved Id value.
+   --  Typically used by a client to indicate absence of a saved Id value.
 
    Cur_Msg : Error_Msg_Id := No_Error_Msg;
    --  Id of most recently posted error message
@@ -140,7 +144,13 @@ package Erroutc is
       --  Text of error message, fully expanded with all insertions
 
       Next : Error_Msg_Id;
-      --  Pointer to next message in error chain
+      --  Pointer to next message in error chain. A value of No_Error_Msg
+      --  indicates the end of the chain.
+
+      Prev : Error_Msg_Id;
+      --  Pointer to previous message in error chain. Only set during the
+      --  Finalize procedure. A value of No_Error_Msg indicates the first
+      --  message in the chain.
 
       Sfile : Source_File_Index;
       --  Source table index of source file. In the case of an error that
@@ -209,30 +219,33 @@ package Erroutc is
    --  error message table, since messages are not always inserted in sequence.
 
    Last_Error_Msg : Error_Msg_Id;
-   --  The last entry on the list of error messages. Note that this is not
-   --  the same as the physically last entry in the error message table, since
-   --  messages are not always inserted in sequence.
+   --  The last entry on the list of error messages. Note: this is not the same
+   --  as the physically last entry in the error message table, since messages
+   --  are not always inserted in sequence.
 
    --------------------------
    -- Warning Mode Control --
    --------------------------
 
-   --  Pragma Warnings allows warnings to be turned off for a specified
-   --  region of code, and the following tabl is the data structure used
-   --  to keep track of these regions.
+   --  Pragma Warnings allows warnings to be turned off for a specified region
+   --  of code, and the following tables are the data structures used to keep
+   --  track of these regions.
+
+   --  The first table is used for the basic command line control, and for the
+   --  forms of Warning with a single ON or OFF parameter.
 
    --  It contains pairs of source locations, the first being the start
    --  location for a warnings off region, and the second being the end
-   --  location. When a pragma Warnings (Off) is encountered, a new entry
-   --  is established extending from the location of the pragma to the
-   --  end of the current source file. A subsequent pragma Warnings (On)
-   --  adjusts the end point of this entry appropriately.
+   --  location. When a pragma Warnings (Off) is encountered, a new entry is
+   --  established extending from the location of the pragma to the end of the
+   --  current source file. A subsequent pragma Warnings (On) adjusts the end
+   --  point of this entry appropriately.
 
-   --  If all warnings are suppressed by comamnd switch, then there is a
-   --  dummy entry (put there by Errout.Initialize) at the start of the
-   --  table which covers all possible Source_Ptr values. Note that the
-   --  source pointer values in this table always reference the original
-   --  template, not an instantiation copy, in the generic case.
+   --  If all warnings are suppressed by command switch, then there is a dummy
+   --  entry (put there by Errout.Initialize) at the start of the table which
+   --  covers all possible Source_Ptr values. Note that the source pointer
+   --  values in this table always reference the original template, not an
+   --  instantiation copy, in the generic case.
 
    type Warnings_Entry is record
       Start : Source_Ptr;
@@ -247,6 +260,56 @@ package Erroutc is
      Table_Increment      => 200,
      Table_Name           => "Warnings");
 
+   --  The second table is used for the specific forms of the pragma, where
+   --  the first argument is ON or OFF, and the second parameter is a string
+   --  which is the entire message to suppress, or a prefix of it.
+
+   type Specific_Warning_Entry is record
+      Start : Source_Ptr;
+      Stop  : Source_Ptr;
+      --  Starting and ending source pointers for the range. These are always
+      --  from the same source file.
+
+      Msg : String_Ptr;
+      --  Message from pragma Warnings (Off, string)
+
+      Open : Boolean;
+      --  Set to True if OFF has been encountered with no matching ON
+
+      Used : Boolean;
+      --  Set to True if entry has been used to suppress a warning
+
+      Config : Boolean;
+      --  True if pragma is configuration pragma (in which case no matching Off
+      --  pragma is required, and it is not required that a specific warning be
+      --  suppressed).
+   end record;
+
+   package Specific_Warnings is new Table.Table (
+     Table_Component_Type => Specific_Warning_Entry,
+     Table_Index_Type     => Natural,
+     Table_Low_Bound      => 1,
+     Table_Initial        => 100,
+     Table_Increment      => 200,
+     Table_Name           => "Specific_Warnings");
+
+   --  Note on handling configuration case versus specific case. A complication
+   --  arises from this example:
+
+   --     pragma Warnings (Off, "not referenced*");
+   --     procedure Mumble (X : Integer) is
+   --     pragma Warnings (On, "not referenced*");
+   --     begin
+   --        null;
+   --     end Mumble;
+
+   --  The trouble is that the first pragma is technically a configuration
+   --  pragma, and yet it is clearly being used in the context of thinking of
+   --  it as a specific case. To deal with this, what we do is that the On
+   --  entry can match a configuration pragma from the same file, and if we
+   --  find such an On entry, we cancel the indication of it being the
+   --  configuration case. This seems to handle all cases we run into ok.
+
    -----------------
    -- Subprograms --
    -----------------
@@ -273,16 +336,16 @@ package Erroutc is
    --  output giving node number (of node N) if the debug X switch is set.
 
    procedure Check_Duplicate_Message (M1, M2 : Error_Msg_Id);
-   --  This function is passed the Id values of two error messages. If
-   --  either M1 or M2 is a continuation message, or is already deleted,
-   --  the call is ignored. Otherwise a check is made to see if M1 and M2
-   --  are duplicated or redundant. If so, the message to be deleted and
-   --  all its continuations are marked with the Deleted flag set to True.
+   --  This function is passed the Id values of two error messages. If either
+   --  M1 or M2 is a continuation message, or is already deleted, the call is
+   --  ignored. Otherwise a check is made to see if M1 and M2 are duplicated or
+   --  redundant. If so, the message to be deleted and all its continuations
+   --  are marked with the Deleted flag set to True.
 
    procedure Output_Error_Msgs (E : in out Error_Msg_Id);
-   --  Output source line, error flag, and text of stored error message and
-   --  all subsequent messages for the same line and unit. On return E is
-   --  set to be one higher than the last message output.
+   --  Output source line, error flag, and text of stored error message and all
+   --  subsequent messages for the same line and unit. On return E is set to be
+   --  one higher than the last message output.
 
    procedure Output_Line_Number (L : Logical_Line_Number);
    --  Output a line number as six digits (with leading zeroes suppressed),
@@ -292,23 +355,25 @@ package Erroutc is
    --  as all blanks, avoiding output of junk line numbers.
 
    procedure Output_Msg_Text (E : Error_Msg_Id);
-   --  Outputs characters of text in the text of the error message E, excluding
-   --  any final exclamation point. Note that no end of line is output, the
-   --  caller is responsible for adding the end of line.
+   --  Outputs characters of text in the text of the error message E. Note that
+   --  no end of line is output, the caller is responsible for adding the end
+   --  of line. If Error_Msg_Line_Length is non-zero, this is the routine that
+   --  splits the line generating multiple lines of output, and in this case
+   --  the last line has no terminating end of line character.
 
    procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr);
    --  All error messages whose location is in the range From .. To (not
    --  including the end points) will be deleted from the error listing.
 
    function Same_Error (M1, M2 : Error_Msg_Id) return Boolean;
-   --  See if two messages have the same text. Returns true if the text
-   --  of the two messages is identical, or if one of them is the same
-   --  as the other with an appended "instance at xxx" tag.
+   --  See if two messages have the same text. Returns true if the text of the
+   --  two messages is identical, or if one of them is the same as the other
+   --  with an appended "instance at xxx" tag.
 
    procedure Set_Msg_Blank;
    --  Sets a single blank in the message if the preceding character is a
-   --  non-blank character other than a left parenthesis. Has no effect if
-   --  manual quote mode is turned on.
+   --  non-blank character other than a left parenthesis or minus. Has no
+   --  effect if manual quote mode is turned on.
 
    procedure Set_Msg_Blank_Conditional;
    --  Sets a single blank in the message if the preceding character is a
@@ -328,6 +393,8 @@ package Erroutc is
    --  location to be referenced, and Flag is the location at which the
    --  flag is posted (used to determine whether to add "in file xxx")
 
+   procedure Set_Msg_Insertion_Name_Literal;
+
    procedure Set_Msg_Insertion_Name;
    --  Handle name insertion (% insertion character)
 
@@ -375,6 +442,32 @@ package Erroutc is
    --  the input value of E was either already No_Error_Msg, or was the
    --  last non-deleted message.
 
+   procedure Set_Specific_Warning_Off
+     (Loc    : Source_Ptr;
+      Msg    : String;
+      Config : Boolean;
+      Used   : Boolean := False);
+   --  This is called in response to the two argument form of pragma Warnings
+   --  where the first argument is OFF, and the second argument is a string
+   --  which identifies a specific warning to be suppressed. The first argument
+   --  is the start of the suppression range, and the second argument is the
+   --  string from the pragma. Loc is the location of the pragma (which is the
+   --  start of the range to suppress). Config is True for the configuration
+   --  pragma case (where there is no requirement for a matching OFF pragma).
+   --  Used is set True to disable the check that the warning actually has
+   --  has the effect of suppressing a warning.
+
+   procedure Set_Specific_Warning_On
+     (Loc : Source_Ptr;
+      Msg : String;
+      Err : out Boolean);
+   --  This is called in response to the two argument form of pragma Warnings
+   --  where the first argument is ON, and the second argument is a string
+   --  which identifies a specific warning to be suppressed. The first argument
+   --  is the end of the suppression range, and the second argument is the
+   --  string from the pragma. Err is set to True on return to report the error
+   --  of no matching Warnings Off pragma preceding this one.
+
    procedure Set_Warnings_Mode_Off (Loc : Source_Ptr);
    --  Called in response to a pragma Warnings (Off) to record the source
    --  location from which warnings are to be turned off.
@@ -385,16 +478,31 @@ package Erroutc is
 
    procedure Test_Style_Warning_Serious_Msg (Msg : String);
    --  Sets Is_Warning_Msg true if Msg is a warning message (contains a
-   --  question mark character), and False otherwise. Sets Is_Style_Msg
-   --  true if Msg is a style message (starts with "(style)"). Sets
-   --  Is_Serious_Error True unless the message is a warning or style
-   --  message or contains the character | indicating a non-serious
-   --  error message. Note that the call has no effect for continuation
-   --  messages (those whose first character is \).
+   --  question mark character), and False otherwise. Is_Style_Msg is set true
+   --  if Msg is a style message (starts with "(style)". Sets Is_Serious_Error
+   --  True unless the message is a warning or style/info message or contains
+   --  the character | indicating a non-serious error message. Note that the
+   --  call has no effect for continuation messages (those whose first
+   --  character is '\').
 
    function Warnings_Suppressed (Loc : Source_Ptr) return Boolean;
    --  Determines if given location is covered by a warnings off suppression
    --  range in the warnings table (or is suppressed by compilation option,
-   --  which generates a warning range for the whole source file).
+   --  which generates a warning range for the whole source file). This routine
+   --  only deals with the general ON/OFF case, not specific warnings. True
+   --  is also returned if warnings are globally suppressed.
+
+   function Warning_Specifically_Suppressed
+     (Loc : Source_Ptr;
+      Msg : String_Ptr) return Boolean;
+   --  Determines if given message to be posted at given location is suppressed
+   --  by specific ON/OFF Warnings pragmas specifying this particular message.
+
+   type Error_Msg_Proc is
+     access procedure (Msg : String; Flag_Location : Source_Ptr);
+   procedure Validate_Specific_Warnings (Eproc : Error_Msg_Proc);
+   --  Checks that specific warnings are consistent (for non-configuration
+   --  case, properly closed, and used). The argument is a pointer to the
+   --  Error_Msg procedure to be called if any inconsistencies are detected.
 
 end Erroutc;