diff gcc/ada/par-ch9.adb @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
line wrap: on
line diff
--- a/gcc/ada/par-ch9.adb	Thu Oct 25 08:08:40 2018 +0900
+++ b/gcc/ada/par-ch9.adb	Thu Oct 25 10:21:07 2018 +0900
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2017, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2018, 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- --
@@ -101,6 +101,7 @@
          Scan; -- past BODY
          Name_Node := P_Defining_Identifier (C_Is);
          Scope.Table (Scope.Last).Labl := Name_Node;
+         Current_Node := Name_Node;
 
          if Token = Tok_Left_Paren then
             Error_Msg_SC ("discriminant part not allowed in task body");
@@ -168,6 +169,7 @@
             Name_Node := P_Defining_Identifier;
             Set_Defining_Identifier (Task_Node, Name_Node);
             Scope.Table (Scope.Last).Labl := Name_Node;
+            Current_Node := Name_Node;
             Set_Discriminant_Specifications
               (Task_Node, P_Known_Discriminant_Part_Opt);
 
@@ -176,6 +178,7 @@
             Name_Node := P_Defining_Identifier (C_Is);
             Set_Defining_Identifier (Task_Node, Name_Node);
             Scope.Table (Scope.Last).Labl := Name_Node;
+            Current_Node := Name_Node;
 
             if Token = Tok_Left_Paren then
                Error_Msg_SC ("discriminant part not allowed for single task");
@@ -447,6 +450,7 @@
          Scan; -- past BODY
          Name_Node := P_Defining_Identifier (C_Is);
          Scope.Table (Scope.Last).Labl := Name_Node;
+         Current_Node := Name_Node;
 
          if Token = Tok_Left_Paren then
             Error_Msg_SC ("discriminant part not allowed in protected body");
@@ -501,6 +505,7 @@
             Name_Node := P_Defining_Identifier (C_Is);
             Set_Defining_Identifier (Protected_Node, Name_Node);
             Scope.Table (Scope.Last).Labl := Name_Node;
+            Current_Node := Name_Node;
             Set_Discriminant_Specifications
               (Protected_Node, P_Known_Discriminant_Part_Opt);
 
@@ -517,6 +522,7 @@
             end if;
 
             Scope.Table (Scope.Last).Labl := Name_Node;
+            Current_Node := Name_Node;
          end if;
 
          P_Aspect_Specifications (Protected_Node, Semicolon => False);
@@ -776,57 +782,82 @@
          return Decl;
       end P_Entry_Or_Subprogram_With_Indicator;
 
+      Result : Node_Id := Empty;
+
    --  Start of processing for P_Protected_Operation_Declaration_Opt
 
    begin
-      --  This loop runs more than once only when a junk declaration
-      --  is skipped.
+      --  This loop runs more than once only when a junk declaration is skipped
 
       loop
-         if Token = Tok_Pragma then
-            return P_Pragma;
-
-         elsif Token = Tok_Not or else Token = Tok_Overriding then
-            return P_Entry_Or_Subprogram_With_Indicator;
-
-         elsif Token = Tok_Entry then
-            return P_Entry_Declaration;
-
-         elsif Token = Tok_Function or else Token = Tok_Procedure then
-            return P_Subprogram (Pf_Decl_Pexp);
-
-         elsif Token = Tok_Identifier then
-            L := New_List;
-            P := Token_Ptr;
-            Skip_Declaration (L);
-
-            if Nkind (First (L)) = N_Object_Declaration then
-               Error_Msg
-                 ("component must be declared in private part of " &
-                  "protected type", P);
-            else
-               Error_Msg
-                 ("illegal declaration in protected definition", P);
-            end if;
-
-         elsif Token in Token_Class_Declk then
-            Error_Msg_SC ("illegal declaration in protected definition");
-            Resync_Past_Semicolon;
-
-            --  Return now to avoid cascaded messages if next declaration
-            --  is a valid component declaration.
-
-            return Error;
-
-         elsif Token = Tok_For then
-            Error_Msg_SC
-              ("representation clause not allowed in protected definition");
-            Resync_Past_Semicolon;
-
-         else
-            return Empty;
-         end if;
+         case Token is
+            when Tok_Pragma =>
+               Result := P_Pragma;
+               exit;
+
+            when Tok_Not
+               | Tok_Overriding
+            =>
+               Result := P_Entry_Or_Subprogram_With_Indicator;
+               exit;
+
+            when Tok_Entry =>
+               Result := P_Entry_Declaration;
+               exit;
+
+            when Tok_Function
+               | Tok_Procedure
+            =>
+               Result := P_Subprogram (Pf_Decl_Pexp);
+               exit;
+
+            when Tok_Identifier =>
+               L := New_List;
+               P := Token_Ptr;
+               Skip_Declaration (L);
+
+               if Nkind (First (L)) = N_Object_Declaration then
+                  Error_Msg
+                    ("component must be declared in private part of " &
+                     "protected type", P);
+               else
+                  Error_Msg
+                    ("illegal declaration in protected definition", P);
+               end if;
+               --  Continue looping
+
+            when Tok_For =>
+               Error_Msg_SC
+                 ("representation clause not allowed in protected definition");
+               Resync_Past_Semicolon;
+               --  Continue looping
+
+            when others =>
+               if Token in Token_Class_Declk then
+                  Error_Msg_SC ("illegal declaration in protected definition");
+                  Resync_Past_Semicolon;
+
+                  --  Return now to avoid cascaded messages if next declaration
+                  --  is a valid component declaration.
+
+                  Result := Error;
+               end if;
+
+               exit;
+         end case;
       end loop;
+
+      if Nkind (Result) = N_Subprogram_Declaration
+        and then Nkind (Specification (Result)) =
+                   N_Procedure_Specification
+        and then Null_Present (Specification (Result))
+      then
+         Error_Msg_N
+           ("protected operation cannot be a null procedure",
+            Null_Statement (Specification (Result)));
+      end if;
+
+      return Result;
    end P_Protected_Operation_Declaration_Opt;
 
    -----------------------------------
@@ -1049,6 +1080,7 @@
       Accept_Node := New_Node (N_Accept_Statement, Token_Ptr);
       Scan; -- past ACCEPT
       Scope.Table (Scope.Last).Labl := Token_Node;
+      Current_Node := Token_Node;
 
       Set_Entry_Direct_Name (Accept_Node, P_Identifier (C_Do));
 
@@ -1197,6 +1229,7 @@
       Name_Node := P_Defining_Identifier;
       Set_Defining_Identifier (Entry_Node, Name_Node);
       Scope.Table (Scope.Last).Labl := Name_Node;
+      Current_Node := Name_Node;
 
       Formal_Part_Node := P_Entry_Body_Formal_Part;
       Set_Entry_Body_Formal_Part (Entry_Node, Formal_Part_Node);