sem_res.adb (Resolve_Op_Not): Warn on double negation
authorRobert Dewar <dewar@adacore.com>
Tue, 20 May 2008 12:51:17 +0000 (14:51 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 20 May 2008 12:51:17 +0000 (14:51 +0200)
2008-05-20  Robert Dewar  <dewar@adacore.com>

* sem_res.adb (Resolve_Op_Not): Warn on double negation

From-SVN: r135644

gcc/ada/sem_res.adb

index 39cd89514fb3fed4fb30522139c2483c6f9e1996..9cc285f11005862dd0ca52020df2778df58852ff 100644 (file)
@@ -6975,6 +6975,19 @@ package body Sem_Res is
             Error_Msg_N ("?not expression should be parenthesized here!", N);
          end if;
 
+         --  Warn on double negation if checking redundant constructs
+
+         if Warn_On_Redundant_Constructs
+           and then Comes_From_Source (N)
+           and then Comes_From_Source (Right_Opnd (N))
+           and then Root_Type (Typ) = Standard_Boolean
+           and then Nkind (Right_Opnd (N)) = N_Op_Not
+         then
+            Error_Msg_N ("redundant double negation?", N);
+         end if;
+
+         --  Complete resolution and evaluation of NOT
+
          Resolve (Right_Opnd (N), B_Typ);
          Check_Unset_Reference (Right_Opnd (N));
          Set_Etype (N, B_Typ);