===================================================================
@@ -2364,6 +2364,7 @@
begin
-- The loop runs more than once only if misplaced pragmas are found
+ -- or if a misplaced unary minus is skipped.
loop
case Token is
@@ -2537,8 +2538,15 @@
return P_Identifier;
end if;
+ -- Minus may well be an improper attempt at a unary minus. Give
+ -- a message, skip the minus and keep going!
+
+ when Tok_Minus =>
+ Error_Msg_SC ("parentheses required for unary minus");
+ Scan; -- past minus
+
-- Anything else is illegal as the first token of a primary, but
- -- we test for a reserved identifier so that it is treated nicely
+ -- we test for some common errors, to improve error messages.
when others =>
if Is_Reserved_Identifier then
This patch gives a warning when unary minus is used in a context that requires parentheses, and no parentheses are present, as shown by the following test: 1. function Test_Mod_B (N: in Integer) return Integer is 2. begin 3. return N mod -10; | >>> parentheses required for unary minus 4. end Test_Mod_B; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-10-29 Robert Dewar <dewar@adacore.com> * par-ch4.adb (P_Primary): Warn on bad use of unary minus.