OSDN Git Service

* decl2.c (maybe_emit_vtables): Produce same comdat group when outputting
[pf3gnuchains/gcc-fork.git] / gcc / ada / par-ch9.adb
index 8e58931..1271d47 100644 (file)
@@ -6,18 +6,17 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2005 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- --
--- 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. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
@@ -25,8 +24,8 @@
 ------------------------------------------------------------------------------
 
 pragma Style_Checks (All_Checks);
---  Turn off subprogram body ordering check. Subprograms are in order
---  by RM section rather than alphabetical
+--  Turn off subprogram body ordering check. Subprograms are in order by RM
+--  section rather than alphabetical.
 
 separate (Par)
 package body Ch9 is
@@ -56,7 +55,8 @@ package body Ch9 is
    --      [is [new INTERFACE_LIST with] TASK_DEFINITION];
 
    --  SINGLE_TASK_DECLARATION ::=
-   --    task DEFINING_IDENTIFIER [is TASK_DEFINITION];
+   --    task DEFINING_IDENTIFIER
+   --      [is [new INTERFACE_LIST with] TASK_DEFINITION];
 
    --  TASK_BODY ::=
    --    task body DEFINING_IDENTIFIER is
@@ -154,7 +154,7 @@ package body Ch9 is
             Scan; -- past semicolon
 
             if Token = Tok_Entry then
-               Error_Msg_SP (""";"" should be IS");
+               Error_Msg_SP ("|"";"" should be IS");
                Set_Task_Definition (Task_Node, P_Task_Definition);
             else
                Pop_Scope_Stack; -- Remove unused entry
@@ -348,7 +348,8 @@ package body Ch9 is
    --      is [new INTERFACE_LIST with] PROTECTED_DEFINITION;
 
    --  SINGLE_PROTECTED_DECLARATION ::=
-   --    protected DEFINING_IDENTIFIER is PROTECTED_DEFINITION;
+   --    protected DEFINING_IDENTIFIER
+   --    is [new INTERFACE_LIST with] PROTECTED_DEFINITION;
 
    --  PROTECTED_BODY ::=
    --    protected body DEFINING_IDENTIFIER is
@@ -370,6 +371,7 @@ package body Ch9 is
       Name_Node      : Node_Id;
       Protected_Node : Node_Id;
       Protected_Sloc : Source_Ptr;
+      Scan_State     : Saved_Scan_State;
 
    begin
       Push_Scope_Stack;
@@ -438,6 +440,35 @@ package body Ch9 is
             Scope.Table (Scope.Last).Labl := Name_Node;
          end if;
 
+         --  Check for semicolon not followed by IS, this is something like
+
+         --    protected type r;
+
+         --  where we want
+
+         --    protected type r IS END;
+
+         if Token = Tok_Semicolon then
+            Save_Scan_State (Scan_State); -- at semicolon
+            Scan; -- past semicolon
+
+            if Token /= Tok_Is then
+               Restore_Scan_State (Scan_State);
+               Error_Msg_SC ("missing IS");
+               Set_Protected_Definition (Protected_Node,
+                 Make_Protected_Definition (Token_Ptr,
+                   Visible_Declarations => Empty_List,
+                   End_Label           => Empty));
+
+               SIS_Entry_Active := False;
+               End_Statements (Protected_Definition (Protected_Node));
+               Scan; -- past semicolon
+               return Protected_Node;
+            end if;
+
+            Error_Msg_SP ("|extra ""("" ignored");
+         end if;
+
          T_Is;
 
          --  Ada 2005 (AI-345)
@@ -446,7 +477,7 @@ package body Ch9 is
             Scan; --  past NEW
 
             if Ada_Version < Ada_05 then
-               Error_Msg_SP ("task interface is an Ada 2005 extension");
+               Error_Msg_SP ("protected interface is an Ada 2005 extension");
                Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
             end if;
 
@@ -465,11 +496,6 @@ package body Ch9 is
             end if;
 
             Scan; -- past WITH
-
-            if Token = Tok_Private then
-               Error_Msg_SP
-                 ("PRIVATE not allowed in protected type declaration");
-            end if;
          end if;
 
          Set_Protected_Definition (Protected_Node, P_Protected_Definition);
@@ -530,8 +556,8 @@ package body Ch9 is
          Append (Item_Node, Visible_Declarations (Def_Node));
       end loop;
 
-      --  Deal with PRIVATE part (including graceful handling
-      --  of multiple PRIVATE parts).
+      --  Deal with PRIVATE part (including graceful handling of multiple
+      --  PRIVATE parts).
 
       Private_Loop : while Token = Tok_Private loop
          if No (Private_Declarations (Def_Node)) then
@@ -609,7 +635,7 @@ package body Ch9 is
 
          if (Is_Overriding or else Not_Overriding) then
             if Ada_Version < Ada_05 then
-               Error_Msg_SP (" overriding indicator is an Ada 2005 extension");
+               Error_Msg_SP ("overriding indicator is an Ada 2005 extension");
                Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
 
             elsif Token = Tok_Entry then
@@ -625,7 +651,8 @@ package body Ch9 is
                Set_Must_Not_Override (Specification (Decl), Not_Overriding);
 
             else
-               Error_Msg_SC ("ENTRY, FUNCTION or PROCEDURE expected!");
+               Error_Msg_SC -- CODEFIX
+                 ("ENTRY, FUNCTION or PROCEDURE expected!");
             end if;
          end if;
 
@@ -710,9 +737,16 @@ package body Ch9 is
          if Token = Tok_Entry or else Bad_Spelling_Of (Tok_Entry) then
             Append (P_Entry_Body, Item_List);
 
+         --  If the operation starts with procedure, function, or an overriding
+         --  indicator ("overriding" or "not overriding"), parse a subprogram.
+
          elsif Token = Tok_Function or else Bad_Spelling_Of (Tok_Function)
                  or else
                Token = Tok_Procedure or else Bad_Spelling_Of (Tok_Procedure)
+                 or else
+               Token = Tok_Overriding or else Bad_Spelling_Of (Tok_Overriding)
+                 or else
+               Token = Tok_Not or else Bad_Spelling_Of (Tok_Not)
          then
             Append (P_Subprogram (Pf_Decl_Pbod), Item_List);
 
@@ -766,7 +800,7 @@ package body Ch9 is
       Not_Overriding : Boolean := False;
 
    begin
-      --  Ada 2005 (AI-397): Scan leading overriding indicator.
+      --  Ada 2005 (AI-397): Scan leading overriding indicator
 
       if Token = Tok_Not then
          Scan;  -- past NOT
@@ -785,7 +819,7 @@ package body Ch9 is
 
       if (Is_Overriding or else Not_Overriding) then
          if Ada_Version < Ada_05 then
-            Error_Msg_SP (" overriding indicator is an Ada 2005 extension");
+            Error_Msg_SP ("overriding indicator is an Ada 2005 extension");
             Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
 
          elsif Token /= Tok_Entry then
@@ -816,7 +850,8 @@ package body Ch9 is
                Restore_Scan_State (Scan_State); -- to Id
                Set_Parameter_Specifications (Decl_Node, P_Formal_Part);
 
-            --  Else if Id wi no comma or colon, must be discrete subtype defn
+            --  Else if Id without comma or colon, must be discrete subtype
+            --  defn
 
             else
                Restore_Scan_State (Scan_State); -- to Id
@@ -860,6 +895,11 @@ package body Ch9 is
 
       TF_Semicolon;
       return Decl_Node;
+
+   exception
+      when Error_Resync =>
+         Resync_Past_Semicolon;
+         return Error;
    end P_Entry_Declaration;
 
    -----------------------------
@@ -1075,7 +1115,7 @@ package body Ch9 is
          Bnode := P_Expression_No_Right_Paren;
 
          if Token = Tok_Colon_Equal then
-            Error_Msg_SC (""":="" should be ""=""");
+            Error_Msg_SC ("|"":="" should be ""=""");
             Scan;
             Bnode := P_Expression_No_Right_Paren;
          end if;
@@ -1322,7 +1362,7 @@ package body Ch9 is
             Ecall_Node := P_Name;
 
             --  ??  The following two clauses exactly parallel code in ch5
-            --      and should be commoned sometime
+            --      and should be combined sometime
 
             if Nkind (Ecall_Node) = N_Indexed_Component then
                declare
@@ -1350,7 +1390,7 @@ package body Ch9 is
             elsif Nkind (Ecall_Node) = N_Identifier
               or else Nkind (Ecall_Node) = N_Selected_Component
             then
-               --  Case of a call to a parameterless entry.
+               --  Case of a call to a parameterless entry
 
                declare
                   C_Node : constant Node_Id :=
@@ -1441,7 +1481,7 @@ package body Ch9 is
 
          End_Statements;
 
-      --  Here we have a selective accept or an an asynchronous select (first
+      --  Here we have a selective accept or an asynchronous select (first
       --  token after SELECT is other than a designator token).
 
       else
@@ -1538,7 +1578,7 @@ package body Ch9 is
 
             else
                Error_Msg_SC
-                 ("Select alternative (ACCEPT, ABORT, DELAY) expected");
+                 ("select alternative (ACCEPT, ABORT, DELAY) expected");
                Alternative := Error;
 
                if Token = Tok_Semicolon then
@@ -1632,7 +1672,7 @@ package body Ch9 is
 
       --  Note: the reason that we accept THEN ABORT as a terminator for
       --  the sequence of statements is for error recovery which allows
-      --  for misuse of an accept statement as a triggering statememt.
+      --  for misuse of an accept statement as a triggering statement.
 
       Set_Statements
         (Accept_Alt_Node, P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm));
@@ -1660,7 +1700,7 @@ package body Ch9 is
 
       --  Note: the reason that we accept THEN ABORT as a terminator for
       --  the sequence of statements is for error recovery which allows
-      --  for misuse of an accept statement as a triggering statememt.
+      --  for misuse of an accept statement as a triggering statement.
 
       Set_Statements
         (Delay_Alt_Node, P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm));