diff options
Diffstat (limited to 'gcc/ada/sem_ch4.adb')
-rw-r--r-- | gcc/ada/sem_ch4.adb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 5ade3a88166..32300126b48 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, 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- -- @@ -62,6 +62,7 @@ with Stand; use Stand; with Sinfo; use Sinfo; with Snames; use Snames; with Tbuild; use Tbuild; +with Uintp; use Uintp; package body Sem_Ch4 is @@ -2637,6 +2638,34 @@ package body Sem_Ch4 is end if; end Analyze_Membership_Op; + ----------------- + -- Analyze_Mod -- + ----------------- + + procedure Analyze_Mod (N : Node_Id) is + begin + -- A special warning check, if we have an expression of the form: + -- expr mod 2 * literal + -- where literal is 64 or less, then probably what was meant was + -- expr mod 2 ** literal + -- so issue an appropriate warning. + + if Warn_On_Suspicious_Modulus_Value + and then Nkind (Right_Opnd (N)) = N_Integer_Literal + and then Intval (Right_Opnd (N)) = Uint_2 + and then Nkind (Parent (N)) = N_Op_Multiply + and then Nkind (Right_Opnd (Parent (N))) = N_Integer_Literal + and then Intval (Right_Opnd (Parent (N))) <= Uint_64 + then + Error_Msg_N + ("suspicious MOD value, was '*'* intended'??", Parent (N)); + end if; + + -- Remaining processing is same as for other arithmetic operators + + Analyze_Arithmetic_Op (N); + end Analyze_Mod; + ---------------------- -- Analyze_Negation -- ---------------------- |