summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-23 12:41:04 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-23 12:41:04 +0000
commitb100b74783bc8e3faff68f533bc9f6928edf4afb (patch)
treee4abe208b98d80262410e962ea433c666904acaf
parentd4734f07090a18288522e64fce2c6dce6ce13c4b (diff)
downloadppe42-gcc-b100b74783bc8e3faff68f533bc9f6928edf4afb.tar.gz
ppe42-gcc-b100b74783bc8e3faff68f533bc9f6928edf4afb.zip
2009-07-23 Robert Dewar <dewar@adacore.com>
* sem_util.adb (Wrong_Type): Special message for cases like A and B = 0 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150004 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/sem_util.adb24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 25793ac3123..8cd32783e1a 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -11077,6 +11077,30 @@ package body Sem_Util is
Error_Msg_NE ("\\found}!", Expr, Found_Type);
end if;
+ -- A special check for cases like M1 and M2 = 0 where M1 and M2 are
+ -- of the same modular type, and (M1 and M2) = 0 was intended.
+
+ if Expec_Type = Standard_Boolean
+ and then Is_Modular_Integer_Type (Found_Type)
+ and then Nkind_In (Parent (Expr), N_Op_And, N_Op_Or, N_Op_Xor)
+ and then Nkind (Right_Opnd (Parent (Expr))) in N_Op_Compare
+ then
+ declare
+ Op : constant Node_Id := Right_Opnd (Parent (Expr));
+ L : constant Node_Id := Left_Opnd (Op);
+ R : constant Node_Id := Right_Opnd (Op);
+ begin
+ if Etype (L) = Found_Type
+ and then Is_Integer_Type (Etype (R))
+ then
+ Error_Msg_N
+ ("\\possible missing parens for modular operation", Expr);
+ end if;
+ end;
+ end if;
+
+ -- Reset error message qualification indication
+
Error_Msg_Qual_Level := 0;
end if;
end Wrong_Type;
OpenPOWER on IntegriCloud