diff gcc/ada/par-ch6.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/gcc/ada/par-ch6.adb	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/ada/par-ch6.adb	Thu Oct 25 07:37:49 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- --
@@ -336,6 +336,7 @@
       end if;
 
       Scope.Table (Scope.Last).Labl := Name_Node;
+      Current_Node := Name_Node;
       Ignore (Tok_Colon);
 
       --  Deal with generic instantiation, the one case in which we do not
@@ -872,7 +873,27 @@
                     New_Node
                       (N_Expression_Function, Sloc (Specification_Node));
                   Set_Specification (Body_Node, Specification_Node);
-                  Set_Expression (Body_Node, P_Expression);
+
+                  declare
+                     Expr : constant Node_Id := P_Expression;
+                  begin
+                     Set_Expression (Body_Node, Expr);
+
+                     --  Check that the full expression is properly
+                     --  parenthesized since we may have a left-operand that is
+                     --  parenthesized but that is not one of the allowed cases
+                     --  with syntactic parentheses.
+
+                     if not (Paren_Count (Expr) /= 0
+                              or else Nkind_In (Expr, N_Aggregate,
+                                                      N_Extension_Aggregate,
+                                                      N_Quantified_Expression))
+                     then
+                        Error_Msg
+                          ("expression function must be enclosed in "
+                           & "parentheses", Sloc (Expr));
+                     end if;
+                  end;
 
                   --  Expression functions can carry pre/postconditions