OSDN Git Service

2009-10-30 Emmanuel Briot <briot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / par-ch6.adb
index b2ae242..ea5df6d 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-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- --
@@ -64,9 +64,8 @@ package body Ch6 is
 
          if Token = Tok_Return then
             Restore_Scan_State (Scan_State);
-            Error_Msg_SC ("unexpected semicolon ignored");
+            Error_Msg_SC ("|extra "";"" ignored");
             Scan; -- rescan past junk semicolon
-
          else
             Restore_Scan_State (Scan_State);
          end if;
@@ -203,7 +202,7 @@ package body Ch6 is
 
       --  Note: in the case of OVERRIDING keyword used in Ada 95 mode, the
       --  declaration circuit already gave an error message and changed the
-      --  tokem to Tok_Overriding.
+      --  token to Tok_Overriding.
 
       elsif Token = Tok_Overriding then
          Scan;  --  past OVERRIDING
@@ -216,15 +215,20 @@ package body Ch6 is
          --  already been given, so no need to give another message here.
 
          --  An overriding indicator is allowed for subprogram declarations,
-         --  bodies, renamings, stubs, and instantiations.
+         --  bodies, renamings, stubs, and instantiations. The test against
+         --  Pf_Decl_Pbod is added to account for the case of subprograms
+         --  declared in a protected type, where only subprogram declarations
+         --  and bodies can occur.
 
-         if Pf_Flags /= Pf_Decl_Gins_Pbod_Rnam_Stub then
+         if Pf_Flags /= Pf_Decl_Gins_Pbod_Rnam_Stub
+              and then
+            Pf_Flags /= Pf_Decl_Pbod
+         then
             Error_Msg_SC ("overriding indicator not allowed here!");
 
-         elsif Token /= Tok_Function
-           and then Token /= Tok_Procedure
-         then
-            Error_Msg_SC ("FUNCTION or PROCEDURE expected!");
+         elsif Token /= Tok_Function and then Token /= Tok_Procedure then
+            Error_Msg_SC -- CODEFIX
+              ("FUNCTION or PROCEDURE expected!");
          end if;
       end if;
 
@@ -265,11 +269,7 @@ package body Ch6 is
       end if;
 
       Scope.Table (Scope.Last).Labl := Name_Node;
-
-      if Token = Tok_Colon then
-         Error_Msg_SC ("redundant colon ignored");
-         Scan; -- past colon
-      end if;
+      Ignore (Tok_Colon);
 
       --  Deal with generic instantiation, the one case in which we do not
       --  have a subprogram specification as part of whatever we are parsing
@@ -411,6 +411,19 @@ package body Ch6 is
          Discard_Junk_Node (P_Expression);
       end if;
 
+      --  Deal with semicolon followed by IS. We want to treat this as IS
+
+      if Token = Tok_Semicolon then
+         Save_Scan_State (Scan_State);
+         Scan; -- past semicolon
+
+         if Token = Tok_Is then
+            Error_Msg_SP ("extra "";"" ignored");
+         else
+            Restore_Scan_State (Scan_State);
+         end if;
+      end if;
+
       --  Deal with case of semicolon ending a subprogram declaration
 
       if Token = Tok_Semicolon then
@@ -424,8 +437,8 @@ package body Ch6 is
          --  semicolon, and go process the body.
 
          if Token = Tok_Is then
-            Error_Msg_SP ("unexpected semicolon ignored");
-            T_Is; -- ignroe redundant IS's
+            Error_Msg_SP ("|extra "";"" ignored");
+            T_Is; -- scan past IS
             goto Subprogram_Body;
 
          --  If BEGIN follows in an appropriate column, we immediately
@@ -436,7 +449,7 @@ package body Ch6 is
          elsif Token = Tok_Begin
             and then Start_Column >= Scope.Table (Scope.Last).Ecol
          then
-            Error_Msg_SP (""";"" should be IS!");
+            Error_Msg_SP ("|"";"" should be IS!");
             goto Subprogram_Body;
 
          else
@@ -540,7 +553,7 @@ package body Ch6 is
          --  semicolon which should really be an IS
 
          else
-            Error_Msg_AP ("missing "";""");
+            Error_Msg_AP ("|missing "";""");
             SIS_Missing_Semicolon_Message := Get_Msg_Id;
             goto Subprogram_Declaration;
          end if;
@@ -1203,7 +1216,7 @@ package body Ch6 is
             --  that semicolon should have been a right parenthesis and exit
 
             if Token = Tok_Is or else Token = Tok_Return then
-               Error_Msg_SP ("expected "")"" in place of "";""");
+               Error_Msg_SP ("|"";"" should be "")""");
                exit Specification_Loop;
             end if;
 
@@ -1289,7 +1302,8 @@ package body Ch6 is
       end if;
 
       if Token = Tok_In then
-         Error_Msg_SC ("IN must precede OUT in parameter mode");
+         Error_Msg_SC -- CODEFIX ???
+           ("IN must precede OUT in parameter mode");
          Scan; -- past IN
          Set_In_Present (Node, True);
       end if;
@@ -1418,7 +1432,8 @@ package body Ch6 is
          Set_Constant_Present (Decl_Node);
 
          if Token = Tok_Aliased then
-            Error_Msg_SC ("ALIASED should be before CONSTANT");
+            Error_Msg_SC -- CODEFIX
+              ("ALIASED should be before CONSTANT");
             Scan; -- past ALIASED
             Set_Aliased_Present (Decl_Node);
          end if;