[Ada] Simplify check for extra parens
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 26 Nov 2020 17:37:09 +0000 (18:37 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 15 Dec 2020 11:41:56 +0000 (06:41 -0500)
gcc/ada/

* par-ch5.adb (P_Condition): Simplify condition for warning
about extra parens and make it easier to understand.

gcc/ada/par-ch5.adb

index ce02af727736399e05a44b33d517c17f706eb3d2..a8d49b1596fbd9bd189fdbcfba8e08c92ca3e87b 100644 (file)
@@ -1306,14 +1306,16 @@ package body Ch5 is
       --  syntax rule.
 
       else
-         if Style_Check and then Paren_Count (Cond) > 0 then
-            if Nkind (Cond) not in N_If_Expression
-                                 | N_Case_Expression
+         if Style_Check
+           and then
+             Paren_Count (Cond) >
+               (if Nkind (Cond) in N_Case_Expression
+                                 | N_If_Expression
                                  | N_Quantified_Expression
-              or else Paren_Count (Cond) > 1
-            then
-               Style.Check_Xtra_Parens (First_Sloc (Cond));
-            end if;
+                then 1
+                else 0)
+         then
+            Style.Check_Xtra_Parens (First_Sloc (Cond));
          end if;
 
          --  And return the result