OSDN Git Service

libitm: Remove unused code.
[pf3gnuchains/gcc-fork.git] / gcc / ada / par-tchk.adb
index 94447fb..6efb1e9 100644 (file)
@@ -6,25 +6,24 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2003 Free Software Foundation, Inc.          --
+--          Copyright (C) 1992-2010, 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.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  Token scan routines.
+--  Token scan routines
 
 --  Error recovery: none of the T_xxx or TF_xxx routines raise Error_Resync
 
@@ -44,10 +43,10 @@ package body Tchk is
    --  position of the error message if the token is missing (see Wrong_Token)
 
    procedure Wrong_Token (T : Token_Type; P : Position);
-   --  Called when scanning a reserved keyword when the keyword is not
-   --  present. T is the token type for the keyword, and P indicates the
-   --  position to be used to place a message relative to the current
-   --  token if the keyword is not located nearby.
+   --  Called when scanning a reserved keyword when the keyword is not present.
+   --  T is the token type for the keyword, and P indicates the position to be
+   --  used to place a message relative to the current token if the keyword is
+   --  not located nearby.
 
    -----------------
    -- Check_Token --
@@ -84,15 +83,18 @@ package body Tchk is
       --  A little recovery helper, accept then in place of =>
 
       elsif Token = Tok_Then then
-         Error_Msg_BC ("missing ""='>""");
+         Error_Msg_BC -- CODEFIX
+           ("|THEN should be ""='>""");
          Scan; -- past THEN used in place of =>
 
       elsif Token = Tok_Colon_Equal then
-         Error_Msg_SC (""":="" should be ""='>""");
+         Error_Msg_SC -- CODEFIX
+           ("|"":="" should be ""='>""");
          Scan; -- past := used in place of =>
 
       else
-         Error_Msg_AP ("missing ""='>""");
+         Error_Msg_AP -- CODEFIX
+           ("missing ""='>""");
       end if;
    end T_Arrow;
 
@@ -123,7 +125,8 @@ package body Tchk is
       if Token = Tok_Box then
          Scan;
       else
-         Error_Msg_AP ("missing ""'<'>""");
+         Error_Msg_AP -- CODEFIX
+           ("missing ""'<'>""");
       end if;
    end T_Box;
 
@@ -136,7 +139,8 @@ package body Tchk is
       if Token = Tok_Colon then
          Scan;
       else
-         Error_Msg_AP ("missing "":""");
+         Error_Msg_AP -- CODEFIX
+           ("missing "":""");
       end if;
    end T_Colon;
 
@@ -150,19 +154,23 @@ package body Tchk is
          Scan;
 
       elsif Token = Tok_Equal then
-         Error_Msg_SC ("""="" should be "":=""");
+         Error_Msg_SC -- CODEFIX
+           ("|""="" should be "":=""");
          Scan;
 
       elsif Token = Tok_Colon then
-         Error_Msg_SC (""":"" should be "":=""");
+         Error_Msg_SC -- CODEFIX
+           ("|"":"" should be "":=""");
          Scan;
 
       elsif Token = Tok_Is then
-         Error_Msg_SC ("IS should be "":=""");
+         Error_Msg_SC -- CODEFIX
+           ("|IS should be "":=""");
          Scan;
 
       else
-         Error_Msg_AP ("missing "":=""");
+         Error_Msg_AP -- CODEFIX
+           ("missing "":=""");
       end if;
    end T_Colon_Equal;
 
@@ -183,7 +191,8 @@ package body Tchk is
          if Token = Tok_Comma then
             Scan;
          else
-            Error_Msg_AP ("missing "",""");
+            Error_Msg_AP -- CODEFIX
+              ("missing "",""");
          end if;
       end if;
 
@@ -201,7 +210,8 @@ package body Tchk is
       if Token = Tok_Dot_Dot then
          Scan;
       else
-         Error_Msg_AP ("missing ""..""");
+         Error_Msg_AP -- CODEFIX
+           ("missing ""..""");
       end if;
    end T_Dot_Dot;
 
@@ -223,7 +233,8 @@ package body Tchk is
       if Token = Tok_Greater_Greater then
          Scan;
       else
-         Error_Msg_AP ("missing ""'>'>""");
+         Error_Msg_AP -- CODEFIX
+           ("missing ""'>'>""");
       end if;
    end T_Greater_Greater;
 
@@ -258,25 +269,43 @@ package body Tchk is
 
    procedure T_Is is
    begin
+      Ignore (Tok_Semicolon);
+
+      --  If we have IS scan past it
+
       if Token = Tok_Is then
          Scan;
 
+         --  And ignore any following semicolons
+
          Ignore (Tok_Semicolon);
 
       --  Allow OF, => or = to substitute for IS with complaint
 
-      elsif Token = Tok_Arrow
-        or else Token = Tok_Of
-        or else Token = Tok_Equal
-      then
-         Error_Msg_SC ("missing IS");
-         Scan; -- token used in place of IS
+      elsif Token = Tok_Arrow then
+         Error_Msg_SC -- CODEFIX
+           ("|""=>"" should be IS");
+         Scan; -- past =>
+
+      elsif Token = Tok_Of then
+         Error_Msg_SC -- CODEFIX
+           ("|OF should be IS");
+         Scan; -- past OF
+
+      elsif Token = Tok_Equal then
+         Error_Msg_SC -- CODEFIX
+           ("|""="" should be IS");
+         Scan; -- past =
+
       else
          Wrong_Token (Tok_Is, AP);
       end if;
 
+      --  Ignore extra IS keywords
+
       while Token = Tok_Is loop
-         Error_Msg_SC ("extra IS ignored");
+         Error_Msg_SC -- CODEFIX
+           ("|extra IS ignored");
          Scan;
       end loop;
    end T_Is;
@@ -290,7 +319,8 @@ package body Tchk is
       if Token = Tok_Left_Paren then
          Scan;
       else
-         Error_Msg_AP ("missing ""(""");
+         Error_Msg_AP -- CODEFIX
+           ("missing ""(""");
       end if;
    end T_Left_Paren;
 
@@ -301,7 +331,8 @@ package body Tchk is
    procedure T_Loop is
    begin
       if Token = Tok_Do then
-         Error_Msg_SC ("LOOP expected");
+         Error_Msg_SC -- CODEFIX
+           ("LOOP expected");
          Scan;
       else
          Check_Token (Tok_Loop, AP);
@@ -380,7 +411,8 @@ package body Tchk is
       if Token = Tok_Right_Paren then
          Scan;
       else
-         Error_Msg_AP ("missing "")""");
+         Error_Msg_AP -- CODEFIX
+           ("|missing "")""");
       end if;
    end T_Right_Paren;
 
@@ -395,48 +427,52 @@ package body Tchk is
          Scan;
 
          if Token = Tok_Semicolon then
-            Error_Msg_SC ("extra "";"" ignored");
+            Error_Msg_SC -- CODEFIX
+              ("|extra "";"" ignored");
             Scan;
          end if;
 
          return;
 
       elsif Token = Tok_Colon then
-         Error_Msg_SC (""":"" should be "";""");
+         Error_Msg_SC -- CODEFIX
+           ("|"":"" should be "";""");
          Scan;
          return;
 
       elsif Token = Tok_Comma then
-         Error_Msg_SC (""","" should be "";""");
+         Error_Msg_SC -- CODEFIX
+           ("|"","" should be "";""");
          Scan;
          return;
 
       elsif Token = Tok_Dot then
-         Error_Msg_SC ("""."" should be "";""");
+         Error_Msg_SC -- CODEFIX
+           ("|""."" should be "";""");
          Scan;
          return;
 
       --  An interesting little kludge here. If the previous token is a
-      --  semicolon, then there is no way that we can legitimately need
-      --  another semicolon. This could only arise in an error situation
-      --  where an error has already been signalled. By simply ignoring
-      --  the request for a semicolon in this case, we avoid some spurious
-      --  missing semicolon messages.
+      --  semicolon, then there is no way that we can legitimately need another
+      --  semicolon. This could only arise in an error situation where an error
+      --  has already been signalled. By simply ignoring the request for a
+      --  semicolon in this case, we avoid some spurious missing semicolon
+      --  messages.
 
       elsif Prev_Token = Tok_Semicolon then
          return;
 
-      --  If the current token is | then this is a reasonable
-      --  place to suggest the possibility of a "C" confusion :-)
+      --  If the current token is | then this is a reasonable place to suggest
+      --  the possibility of a "C" confusion.
 
       elsif Token = Tok_Vertical_Bar then
-         Error_Msg_SC ("unexpected occurrence of ""'|"", did you mean OR'?");
+         Error_Msg_SC -- CODEFIX
+           ("unexpected occurrence of ""'|"", did you mean OR'?");
          Resync_Past_Semicolon;
          return;
 
-      --  Deal with pragma. If pragma is not at start of line, it is
-      --  considered misplaced otherwise we treat it as a normal
-      --  missing semicolong case.
+      --  Deal with pragma. If pragma is not at start of line, it is considered
+      --  misplaced otherwise we treat it as a normal missing semicolon case.
 
       elsif Token = Tok_Pragma
         and then not Token_Is_At_Start_Of_Line
@@ -451,7 +487,8 @@ package body Tchk is
 
       --  If none of those tests return, we really have a missing semicolon
 
-      Error_Msg_AP ("|missing "";""");
+      Error_Msg_AP -- CODEFIX
+        ("|missing "";""");
       return;
    end T_Semicolon;
 
@@ -633,7 +670,8 @@ package body Tchk is
          Scan; -- skip RETURN and we are done
 
       else
-         Error_Msg_SC ("missing RETURN");
+         Error_Msg_SC -- CODEFIX
+           ("missing RETURN");
          Save_Scan_State (Scan_State); -- at start of junk tokens
 
          loop
@@ -680,7 +718,7 @@ package body Tchk is
       else
          --  Deal with pragma. If pragma is not at start of line, it is
          --  considered misplaced otherwise we treat it as a normal
-         --  missing semicolong case.
+         --  missing semicolon case.
 
          if Token = Tok_Pragma
            and then not Token_Is_At_Start_Of_Line
@@ -697,13 +735,15 @@ package body Tchk is
 
          T_Semicolon;
 
-         --  Scan out junk on rest of line
+         --  Scan out junk on rest of line. Scan stops on END keyword, since
+         --  that seems to help avoid cascaded errors.
 
          Save_Scan_State (Scan_State); -- at start of junk tokens
 
          loop
             if Prev_Token_Ptr < Current_Line_Start
               or else Token = Tok_EOF
+              or else Token = Tok_End
             then
                Restore_Scan_State (Scan_State); -- to where we were
                return;
@@ -790,27 +830,51 @@ package body Tchk is
       end if;
    end TF_Use;
 
+   ------------------
+   -- U_Left_Paren --
+   ------------------
+
+   procedure U_Left_Paren is
+   begin
+      if Token = Tok_Left_Paren then
+         Scan;
+      else
+         Error_Msg_AP -- CODEFIX
+           ("missing ""(""!");
+      end if;
+   end U_Left_Paren;
+
+   -------------------
+   -- U_Right_Paren --
+   -------------------
+
+   procedure U_Right_Paren is
+   begin
+      if Token = Tok_Right_Paren then
+         Scan;
+      else
+         Error_Msg_AP -- CODEFIX
+           ("|missing "")""!");
+      end if;
+   end U_Right_Paren;
+
    -----------------
    -- Wrong_Token --
    -----------------
 
    procedure Wrong_Token (T : Token_Type; P : Position) is
-      Missing : constant String := "missing ";
-      Image : constant String := Token_Type'Image (T);
+      Missing  : constant String := "missing ";
+      Image    : constant String := Token_Type'Image (T);
       Tok_Name : constant String := Image (5 .. Image'Length);
-      M : String (1 .. Missing'Length + Tok_Name'Length);
+      M        : constant String := Missing & Tok_Name;
 
    begin
-      --  Set M to Missing & Tok_Name.
-
-      M (1 .. Missing'Length) := Missing;
-      M (Missing'Length + 1 .. M'Last) := Tok_Name;
-
       if Token = Tok_Semicolon then
          Scan;
 
          if Token = T then
-            Error_Msg_SP ("extra "";"" ignored");
+            Error_Msg_SP -- CODEFIX
+              ("|extra "";"" ignored");
             Scan;
          else
             Error_Msg_SP (M);
@@ -820,7 +884,8 @@ package body Tchk is
          Scan;
 
          if Token = T then
-            Error_Msg_SP ("extra "","" ignored");
+            Error_Msg_SP -- CODEFIX
+              ("|extra "","" ignored");
             Scan;
 
          else