+2018-01-11 Justin Squirek <squirek@adacore.com>
+
+ * par-ch6.adb (Scan_Body_Or_Expression_Function): Add additional check
+ to make sure a given expression function is properly parenthesized.
+
2018-01-11 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Check the
-- --
-- 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- --
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
+2018-01-11 Justin Squirek <squirek@adacore.com>
+
+ * gnat.dg/expr_func4.adb: New testcase.
+
2018-01-11 Hristian Kirtchev <kirtchev@adacore.com>
* gnat.dg/pure_subp_body.adb, gnat.dg/pure_subp_body_pkg.ads: New