[Ada] Don't emit style errors when parens are required
authorGhjuvan Lacambre <lacambre@adacore.com>
Mon, 11 Jan 2021 15:26:45 +0000 (16:26 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 5 May 2021 08:19:02 +0000 (04:19 -0400)
gcc/ada/

* par-ch5.adb (P_Condition): Check if expression is declare
expression.

gcc/ada/par-ch5.adb

index 9d0ac2c..7f82557 100644 (file)
@@ -1299,17 +1299,16 @@ package body Ch5 is
 
          return Cond;
 
-      --  Otherwise check for redundant parentheses
-
-      --  If the condition is a conditional or a quantified expression, it is
-      --  parenthesized in the context of a condition, because of a separate
-      --  syntax rule.
+      --  Otherwise check for redundant parentheses but do not emit messages
+      --  about expressions that require parentheses (e.g. conditional,
+      --  quantified or declaration expressions).
 
       else
          if Style_Check
            and then
              Paren_Count (Cond) >
                (if Nkind (Cond) in N_Case_Expression
+                                 | N_Expression_With_Actions
                                  | N_If_Expression
                                  | N_Quantified_Expression
                 then 1